2012-02-09 5 views
5

PageCollectedView.GroupDescriptionsPropertyGroupDescriptionを追加すると、プロパティ名としてnullが指定され、IValueConverterが指定されます。私はこれを行って、プロパティ値のセットに対して単一のグループ化を行うことができます。ディスプレイには、DataGridのグループ化値の前に先頭が表示されます。グループ名をプロパティ名からよりわかりやすいものに変更する方法

別の状況では、1つのプロパティでグループ化するため、PropertyGroupDescriptionのインスタンスにプロパティ名を指定し、IValueConverterは指定しません。その場合、表示にはプロパティ名がコロンとグループ化の値が表示されます。

私はプログラム的に前に表示されるテキストの表示に設定できるようにする必要があります:より有意義なものに(そのことについては、地域の言語では、それは後で来る)

+0

は、あなたはそれが作業を取得するために管理するのですか?私は全く同じ問題を抱えています。 – Jamie

+0

@Jamie - 悲しいことに、私は今、そのアイデアを棚上げしなければなりませんでした。私は決して答えを見つけませんでした。 –

答えて

0

これらのコードを使用して、あなたを願っています問題は解決されます。ここで

 <sdk:DataGrid.RowGroupHeaderStyles> 
      <Style TargetType="sdk:DataGridRowGroupHeader"> 
       <Setter Property="Cursor" Value="Arrow" /> 
       <Setter Property="IsTabStop" Value="False" /> 
       <Setter Property="Background" Value="#FFE4E8EA" /> 
       <Setter Property="Height" Value="20"/> 
       <Setter Property="Template"> 
        <Setter.Value> 
         <ControlTemplate TargetType="sdk:DataGridRowGroupHeader"> 
          <sdk:DataGridFrozenGrid x:Name="Root" 
                Background="{TemplateBinding Background}"> 
           <sdk:DataGridFrozenGrid.Resources> 
            <ControlTemplate x:Key="ToggleButtonTemplate" 
                TargetType="ToggleButton"> 
             <Grid> 
              <VisualStateManager.VisualStateGroups> 
               <VisualStateGroup x:Name="CommonStates"> 
                <VisualState x:Name="Normal"/> 
                <VisualState x:Name="MouseOver"> 
                 <Storyboard> 
                  <ColorAnimation Storyboard.TargetName="CollapsedArrow" 
                      Storyboard.TargetProperty="(Stroke).Color" 
                      Duration="0" To="#FF6DBDD1"/> 
                  <ColorAnimation Storyboard.TargetName="ExpandedArrow" 
                      Storyboard.TargetProperty="(Fill).Color" 
                      Duration="0" To="#FF6DBDD1"/> 
                 </Storyboard> 
                </VisualState> 
                <VisualState x:Name="Pressed"> 
                 <Storyboard> 
                  <ColorAnimation Storyboard.TargetName="CollapsedArrow" 
                      Storyboard.TargetProperty="(Stroke).Color" 
                      Duration="0" To="#FF6DBDD1"/> 
                  <ColorAnimation Storyboard.TargetName="ExpandedArrow" 
                      Storyboard.TargetProperty="(Fill).Color" 
                      Duration="0" To="#FF6DBDD1"/> 
                 </Storyboard> 
                </VisualState> 
                <VisualState x:Name="Disabled"> 
                 <Storyboard> 
                  <DoubleAnimation Duration="0" 
                      Storyboard.TargetName="CollapsedArrow" 
                      Storyboard.TargetProperty="Opacity" To=".5"/> 
                  <DoubleAnimation Duration="0" 
                      Storyboard.TargetName="ExpandedArrow" 
                      Storyboard.TargetProperty="Opacity" To=".5"/> 
                 </Storyboard> 
                </VisualState> 
               </VisualStateGroup> 
               <VisualStateGroup x:Name="CheckStates"> 
                <VisualState x:Name="Checked" /> 
                <VisualState x:Name="Unchecked"> 
                 <Storyboard> 
                  <ObjectAnimationUsingKeyFrames Duration="0" 
                          Storyboard.TargetName="CollapsedArrow" 
                          Storyboard.TargetProperty="Visibility"> 
                   <DiscreteObjectKeyFrame KeyTime="0" 
                         Value="Visible"/> 
                  </ObjectAnimationUsingKeyFrames> 
                  <ObjectAnimationUsingKeyFrames Duration="0" 
                          Storyboard.TargetName="ExpandedArrow" 
                          Storyboard.TargetProperty="Visibility"> 
                   <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/> 
                  </ObjectAnimationUsingKeyFrames> 
                 </Storyboard> 
                </VisualState> 
               </VisualStateGroup> 
              </VisualStateManager.VisualStateGroups> 

              <Path Stretch="Uniform" 
                Data="F1 M 0,0 L 0,1 L .6,.5 L 0,0 Z" 
                Width="5" HorizontalAlignment="Center" 
                VerticalAlignment="Center" x:Name="CollapsedArrow" 
                Visibility="Collapsed" Stroke="#FF414345"/> 
              <Path Stretch="Uniform" 
                Data="F1 M 0,1 L 1,1 L 1,0 L 0,1 Z" Width="6" 
                HorizontalAlignment="Center" VerticalAlignment="Center" 
                x:Name="ExpandedArrow" Fill="#FF414345"/> 
             </Grid> 
            </ControlTemplate> 
           </sdk:DataGridFrozenGrid.Resources> 

           <VisualStateManager.VisualStateGroups> 
            <VisualStateGroup x:Name="CurrentStates"> 
             <VisualState x:Name="Regular"/> 
             <VisualState x:Name="Current"> 
              <Storyboard> 
               <DoubleAnimation Storyboard.TargetName="FocusVisual" 
                   Storyboard.TargetProperty="Opacity" 
                   To="1" Duration="0" /> 
              </Storyboard> 
             </VisualState> 
            </VisualStateGroup> 
           </VisualStateManager.VisualStateGroups> 

           <sdk:DataGridFrozenGrid.ColumnDefinitions> 
            <ColumnDefinition Width="Auto" /> 
            <ColumnDefinition Width="Auto" /> 
            <ColumnDefinition Width="Auto" /> 
            <ColumnDefinition Width="Auto" /> 
            <ColumnDefinition/> 
           </sdk:DataGridFrozenGrid.ColumnDefinitions> 
           <sdk:DataGridFrozenGrid.RowDefinitions> 
            <RowDefinition Height="Auto"/> 
            <RowDefinition/> 
            <RowDefinition Height="Auto"/> 
           </sdk:DataGridFrozenGrid.RowDefinitions> 

           <Rectangle Grid.Column="1" Grid.ColumnSpan="5" Fill="#FFFFFFFF" Height="1"/> 
           <Rectangle Grid.Column="1" Grid.Row="1" x:Name="IndentSpacer" /> 
           <ToggleButton Grid.Column="2" Grid.Row="1" x:Name="ExpanderButton" 
               Height="15" Width="15" IsTabStop="False" 
               Template="{StaticResource ToggleButtonTemplate}" Margin="2,0,0,0"/> 

           <!-- This is START of the First Group Header of the DataGrid --> 
           <!--<StackPanel Grid.Column="3" Grid.Row="1" Orientation="Horizontal" 
              VerticalAlignment="Center" Margin="0,1,0,1" 
              Visibility="{Binding Width, ElementName=IndentSpacer}"> 
            <TextBlock Margin="4,0,0,0" Text="{Binding Name}" Foreground="Red"/> 
           </StackPanel>--> 
           <!-- This is END of the First Group Header of the DataGrid --> 

           <!-- This is START of the Second Group Header of the DataGrid --> 
           <Grid Grid.Column="3" Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Stretch" Margin="0,1,0,1" 
             Visibility="{Binding Width, ElementName=IndentSpacer}"> 
            <StackPanel Orientation="Horizontal" HorizontalAlignment="Left"> 
             <!--<ComboBox Margin="4,0,0,0" Width="120" ItemsSource="{Binding ItemsSource,ElementName=personDataGrid,Converter={StaticResource ConvToComboBox}}" DisplayMemberPath="text" SelectionChanged="comboSelectionChangeda"/> 
             <Button Margin="169,0,0,0" Height="15" Name="btn" Content="+" FontSize="9" Foreground="Black" FontWeight="Bold" Click="btn_Click"/>--> 
             <sdk:Label Content="{Binding ItemsSource,ElementName=personDataGrid,Converter={StaticResource ConvToGender}}"/> 

            </StackPanel> 

           </Grid> 
           <!-- This is END of Second Group Header of the DataGrid --> 

           <Rectangle Grid.Column="1" Grid.ColumnSpan="5" Fill="#FFD3D3D3" Height="1" Grid.Row="2"/> 
           <Rectangle x:Name="FocusVisual" Grid.Column="1" Grid.ColumnSpan="4" Grid.RowSpan="3" 
            Stroke="#FF6DBDD1" StrokeThickness="1" 
            HorizontalAlignment="Stretch" VerticalAlignment="Stretch" 
            IsHitTestVisible="false" Opacity="0" /> 
           <sdk:DataGridRowHeader x:Name="RowHeader" Grid.RowSpan="3" sdk:DataGridFrozenGrid.IsFrozen="True"/> 

          </sdk:DataGridFrozenGrid> 
         </ControlTemplate> 
        </Setter.Value> 
       </Setter> 
      </Style> 
     </sdk:DataGrid.RowGroupHeaderStyles> 

は、グループヘッダー

をカスタマイズ

パブリッククラスGenderConvを返すConverterクラスです:IValueConverter は{

public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 
    { 
     PagedCollectionView pageView = value as PagedCollectionView; 
     Person person = pageView.CurrentItem as Person; 
     string gender = person.Gender.ToString(); 
     return "Sex:"+ gender; 
    } 

    public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 
    { 
     throw new NotImplementedException(); 
    } 
} 
関連する問題