WPF进阶技巧和实战03-控件(5-列表、树、网格04)
阅读原文时间:2022年05月20日阅读:11

ListView控件

ListView继承自简单的没有特色的ListBox,增加了对基于列显示的支持,并增加了快速切换视图或显示模式的能力,而不需要重新绑定数据以重新构建列表。

ListView类继承自ListBox类,并使用View属性进行扩展(可以创建丰富的列表)。通过两个样式来设置View,一个用于ListView控件,一个用于ListView控件的项。

使用GridView创建列

GridView类继承自ViewBase类,表示具有多列的列表视图,通过GridView.Columns集合添加GridViewColumn对象来定义列。

<ListView ItemsSource="{Binding DataList}">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<ListView.View>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<GridView>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<GridViewColumn Width="80" Header="{ex:Lang Key={x:Static langs:LangKeys.Index}}" DisplayMemberBinding="{Binding Index}"/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<GridViewColumn Width="100" Header="{ex:Lang Key={x:Static langs:LangKeys.Name}}" DisplayMemberBinding="{Binding Name}"/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<GridViewColumn Width="200" Header="{ex:Lang Key={x:Static langs:LangKeys.Remark}}" DisplayMemberBinding="{Binding Remark}"/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</GridView>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</ListView.View>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</ListView>

Head属性提供放在列顶部的文本,DisplayMemberBinding设置每个数据项要显示的信息。

  • 改变列的尺寸,可以设置固定宽度,但是会出现过长的数据被截断。没有MaxWidth和MinWidth属性。如果希望完全禁止改变列的尺寸,唯一办法就是为标题提供新模板

  • 单元格模板,为了显示数据,可以使用更高级的方式,为每个列设置CellTemplate属性(使用数据模板)

                                                                                                                                                                                                                                                                                  

  • 自定义列标题,如果希望用自己的内容填充列标题,但又不希望单独给每列指定内容,可以使用GridViewColumn.HeaderTemplate属性定一个数据模板,这个数据模板可以绑定到Header属性中指定内容。如果希望重新定义指定列的标题,可以使用GridViewColumn.HeaderContainerStyle属性提供样式。如果希望以相同的方式重新定义所有列的标题,就需要使用GridView.ColumnHeaderContainerStyle属性。可以使用GridViewColumn.HeaderTemplate和GridView.ColumnHeaderTemplate改变指定列和所有列的外观。

自定义ListView的样式

可以通过改变ListView的样式来实现自定义的样式和模板

<Style x:Key="GridViewColumnHeaderGripper" TargetType="Thumb">
&nbsp; &nbsp; <Setter Property="Canvas.Right" Value="-9"/>
&nbsp; &nbsp; <Setter Property="Width" Value="18"/>
&nbsp; &nbsp; <Setter Property="Height" Value="{Binding ActualHeight, RelativeSource={RelativeSource TemplatedParent}}"/>
&nbsp; &nbsp; <Setter Property="Padding" Value="0"/>
&nbsp; &nbsp; <Setter Property="Background" Value="Transparent"/>
&nbsp; &nbsp; <Setter Property="Template">
&nbsp; &nbsp; &nbsp; &nbsp; <Setter.Value>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <ControlTemplate TargetType="Thumb">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Border Background="Transparent" Padding="{TemplateBinding Padding}">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Rectangle Fill="{TemplateBinding Background}" HorizontalAlignment="Center" Width="1"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </Border>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </ControlTemplate>
&nbsp; &nbsp; &nbsp; &nbsp; </Setter.Value>
&nbsp; &nbsp; </Setter>
</Style>
<Style TargetType="GridViewColumnHeader">
&nbsp; &nbsp; <Setter Property="VerticalContentAlignment" Value="Center"/>
&nbsp; &nbsp; <Setter Property="HorizontalContentAlignment" Value="Left"/>
&nbsp; &nbsp; <Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"/>
&nbsp; &nbsp; <Setter Property="Padding" Value="12,6,12,12"/>
&nbsp; &nbsp; <Setter Property="MinHeight" Value="44"/>
&nbsp; &nbsp; <Setter Property="Template">
&nbsp; &nbsp; &nbsp; &nbsp; <Setter.Value>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <ControlTemplate TargetType="GridViewColumnHeader">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <hc:SimplePanel SnapsToDevicePixels="true">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Border x:Name="HeaderBorder" BorderBrush="{TemplateBinding BorderBrush}" Background="Transparent">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <ContentPresenter x:Name="HeaderContent" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </Border>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Canvas>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Thumb x:Name="PART_HeaderGripper" Style="{StaticResource GridViewColumnHeaderGripper}"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </Canvas>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </hc:SimplePanel>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </ControlTemplate>
&nbsp; &nbsp; &nbsp; &nbsp; </Setter.Value>
&nbsp; &nbsp; </Setter>
</Style>
<Style x:Key="ListViewItemBaseStyle" TargetType="ListViewItem">
&nbsp; &nbsp; <Setter Property="Background" Value="{DynamicResource RegionBrush}"/>
&nbsp; &nbsp; <Setter Property="BorderThickness" Value="0"/>
&nbsp; &nbsp; <Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"/>
&nbsp; &nbsp; <Setter Property="SnapsToDevicePixels" Value="true"/>
&nbsp; &nbsp; <Setter Property="Margin" Value="0,0,0,4"/>
&nbsp; &nbsp; <Setter Property="Padding" Value="{StaticResource DefaultControlPadding}"/>
&nbsp; &nbsp; <Setter Property="MinHeight" Value="44"/>
&nbsp; &nbsp; <Setter Property="Template">
&nbsp; &nbsp; &nbsp; &nbsp; <Setter.Value>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <ControlTemplate TargetType="ListViewItem">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Border CornerRadius="4" x:Name="Bd" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="true">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <GridViewRowPresenter Content="{TemplateBinding Content}" Columns="{TemplateBinding GridView.ColumnCollection}"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </Border>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </ControlTemplate>
&nbsp; &nbsp; &nbsp; &nbsp; </Setter.Value>
&nbsp; &nbsp; </Setter>
&nbsp; &nbsp; <Style.Triggers>
&nbsp; &nbsp; &nbsp; &nbsp; <Trigger Property="IsMouseOver" Value="true">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="Background" Value="{DynamicResource DarkDefaultBrush}"/>
&nbsp; &nbsp; &nbsp; &nbsp; </Trigger>
&nbsp; &nbsp; &nbsp; &nbsp; <Trigger Property="IsSelected" Value="True">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="Background" Value="{DynamicResource PrimaryBrush}"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="TextElement.Foreground" Value="{DynamicResource TextIconBrush}"/>
&nbsp; &nbsp; &nbsp; &nbsp; </Trigger>
&nbsp; &nbsp; &nbsp; &nbsp; <MultiTrigger>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <MultiTrigger.Conditions>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Condition Property="IsSelected" Value="true"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Condition Property="Selector.IsSelectionActive" Value="false"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </MultiTrigger.Conditions>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="Background" Value="{DynamicResource DarkDefaultBrush}"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"/>
&nbsp; &nbsp; &nbsp; &nbsp; </MultiTrigger>
&nbsp; &nbsp; </Style.Triggers>
</Style>
<Style TargetType="ListView">
&nbsp; &nbsp; <Setter Property="Background" Value="{DynamicResource SecondaryRegionBrush}"/>
&nbsp; &nbsp; <Setter Property="BorderBrush" Value="{DynamicResource BorderBrush}"/>
&nbsp; &nbsp; <Setter Property="BorderThickness" Value="1"/>
&nbsp; &nbsp; <Setter Property="Padding" Value="6"/>
&nbsp; &nbsp; <Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"/>
&nbsp; &nbsp; <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
&nbsp; &nbsp; <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
&nbsp; &nbsp; <Setter Property="ScrollViewer.CanContentScroll" Value="true"/>
&nbsp; &nbsp; <Setter Property="ScrollViewer.PanningMode" Value="Both"/>
&nbsp; &nbsp; <Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
&nbsp; &nbsp; <Setter Property="VerticalContentAlignment" Value="Center"/>
&nbsp; &nbsp; <Setter Property="ItemContainerStyle" Value="{StaticResource ListViewItemBaseStyle}"/>
&nbsp; &nbsp; <Setter Property="Template">
&nbsp; &nbsp; &nbsp; &nbsp; <Setter.Value>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <ControlTemplate TargetType="ListView">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="True">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <hc:ToggleBlock IsChecked="{Binding HasItems,RelativeSource={RelativeSource TemplatedParent},Mode=OneWay}" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <hc:ToggleBlock.CheckedContent>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <ScrollViewer>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Grid Background="{TemplateBinding Background}" SnapsToDevicePixels="True">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Grid.RowDefinitions>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <RowDefinition Height="Auto"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <RowDefinition Height="*"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </Grid.RowDefinitions>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <GridViewHeaderRowPresenter AllowsColumnReorder="{Binding View.AllowsColumnReorder, RelativeSource={RelativeSource TemplatedParent}}" ColumnHeaderContainerStyle="{Binding View.ColumnHeaderContainerStyle, RelativeSource={RelativeSource TemplatedParent}}" ColumnHeaderToolTip="{Binding View.ColumnHeaderToolTip, RelativeSource={RelativeSource TemplatedParent}}" ColumnHeaderContextMenu="{Binding View.ColumnHeaderContextMenu, RelativeSource={RelativeSource TemplatedParent}}" ColumnHeaderTemplate="{Binding View.ColumnHeaderTemplate, RelativeSource={RelativeSource TemplatedParent}}" Columns="{Binding View.Columns, RelativeSource={RelativeSource TemplatedParent}}" Margin="2,0" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <ItemsPresenter Grid.Row="1"&nbsp; SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </Grid>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </ScrollViewer>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </hc:ToggleBlock.CheckedContent>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <hc:ToggleBlock.UnCheckedContent>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <hc:Empty />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </hc:ToggleBlock.UnCheckedContent>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </hc:ToggleBlock>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </Border>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </ControlTemplate>
&nbsp; &nbsp; &nbsp; &nbsp; </Setter.Value>
&nbsp; &nbsp; </Setter>
&nbsp; &nbsp; <Style.Triggers>
&nbsp; &nbsp; &nbsp; &nbsp; <MultiTrigger>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <MultiTrigger.Conditions>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Condition Property="IsGrouping" Value="true"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Condition Property="VirtualizingPanel.IsVirtualizingWhenGrouping" Value="false"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </MultiTrigger.Conditions>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
&nbsp; &nbsp; &nbsp; &nbsp; </MultiTrigger>
&nbsp; &nbsp; </Style.Triggers>
</Style>

TreeView控件

TreeView是层次化容器,这意味着可创建多层数据展示。例如,可创建在第一级中显示类别组,并在每个类别节点中显示相关产品的TreeView控件。

TreeView控件本质上时驻留TreeViewItem对象的特殊ItemsControl控件。每个TreeViewItem对象都是单独的ItemsControl控件,所以可以嵌套的包含更多的TreeViewItem对象。

数据绑定

我们可以通过下面的数据源进行绑定到TreeView的ItemsSrouce。通过创建属性提供另一个集合的集合,是实现数据绑定导航父子关系的诀窍。

public class TreeItem : BindableBase
&nbsp; &nbsp; {
&nbsp; &nbsp; &nbsp; &nbsp; public TreeItem(object Item)
&nbsp; &nbsp; &nbsp; &nbsp; {
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this.Item = Item;
&nbsp; &nbsp; &nbsp; &nbsp; }
&nbsp; &nbsp; &nbsp; &nbsp; //父
&nbsp; &nbsp; &nbsp; &nbsp; public TreeItem Parent { get => _parent; set => SetProperty(ref _parent, value); }
&nbsp; &nbsp; &nbsp; &nbsp; private TreeItem _parent;
&nbsp; &nbsp; &nbsp; &nbsp; //子
&nbsp; &nbsp; &nbsp; &nbsp; public ObservableCollection<TreeItem> Children { get; set; } = new ObservableCollection<TreeItem>();
&nbsp; &nbsp; &nbsp; &nbsp; //级别
&nbsp; &nbsp; &nbsp; &nbsp; public int IndexLevel { get; set; }
&nbsp; &nbsp; &nbsp; &nbsp; //节点的数据
&nbsp; &nbsp; &nbsp; &nbsp; public object Item { get => _item; set => SetProperty(ref _item, value); }
&nbsp; &nbsp; &nbsp; &nbsp; private object _item;
&nbsp; &nbsp; &nbsp; &nbsp; //节点图标路径
&nbsp; &nbsp; &nbsp; &nbsp; public string ItemIcon { get; set; }
&nbsp; &nbsp; &nbsp; &nbsp; //是否展开
&nbsp; &nbsp; &nbsp; &nbsp; public bool IsExpanded { get => _isExpanded; set => SetProperty(ref _isExpanded, value); }
&nbsp; &nbsp; &nbsp; &nbsp; private bool _isExpanded;

&nbsp; &nbsp; &nbsp; &nbsp; //CheckBox是否选中
&nbsp; &nbsp; &nbsp; &nbsp; public bool? IsChecked { get => _isChecked; set => SetIsChecked(value, true, true); }
&nbsp; &nbsp; &nbsp; &nbsp; private bool? _isChecked;
&nbsp; &nbsp; &nbsp; &nbsp; private void SetIsChecked(bool? value, bool checkedChildren, bool checkedParent)
&nbsp; &nbsp; &nbsp; &nbsp; {
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (_isChecked == value) return;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _isChecked = value;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //选中和取消子类
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (checkedChildren && value.HasValue && Children != null)
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Children.ToList().ForEach(ch => ch.SetIsChecked(value, true, false));
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //选中和取消父类
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (checkedParent && this.Parent != null)
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this.Parent.CheckParentCheckState();
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //通知更改
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this.SetProperty(ref _isChecked, value);
&nbsp; &nbsp; &nbsp; &nbsp; }
&nbsp; &nbsp; &nbsp; &nbsp; //检查父类是否选中(如果父类的子类中有一个和第一个子类的状态不一样父类ischecked为null)
&nbsp; &nbsp; &nbsp; &nbsp; private void CheckParentCheckState()
&nbsp; &nbsp; &nbsp; &nbsp; {
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bool? _currentState = this.IsChecked;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bool? _firstState = null;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (int i = 0; i < this.Children.Count(); i++)
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bool? childrenState = this.Children[i].IsChecked;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (i == 0)
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _firstState = childrenState;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (_firstState != childrenState)
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _firstState = null;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (_firstState != null) _currentState = _firstState;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SetIsChecked(_firstState, false, true);
&nbsp; &nbsp; &nbsp; &nbsp; }

&nbsp; &nbsp; &nbsp; &nbsp; //选中的行 IsSelected
&nbsp; &nbsp; &nbsp; &nbsp; public bool? IsSelected
&nbsp; &nbsp; &nbsp; &nbsp; {
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; get => _isSelected;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; set
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _isSelected = value;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this.SetProperty(ref _isSelected, value);
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (value.HasValue && value.Value)
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SelectedTreeItem = this;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //MessageBox.Show("选中的是" + SelectedTreeItem.Name);
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SelectedTreeItem = null;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }
&nbsp; &nbsp; &nbsp; &nbsp; }
&nbsp; &nbsp; &nbsp; &nbsp; private bool? _isSelected;

&nbsp; &nbsp; &nbsp; &nbsp; //选中的数据
&nbsp; &nbsp; &nbsp; &nbsp; public TreeItem SelectedTreeItem { get; set; }

&nbsp; &nbsp; &nbsp; &nbsp; //创建树
&nbsp; &nbsp; &nbsp; &nbsp; public void CreateTreeWithChildren(TreeItem children, bool? isChecked = null)
&nbsp; &nbsp; &nbsp; &nbsp; {
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this.Children.Add(children);
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; children.Parent = this;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; children.IsChecked = isChecked;
&nbsp; &nbsp; &nbsp; &nbsp; }
&nbsp; &nbsp; }

TreeViewItem类继承自HeaderedItemsControl类,添加了Header属性,该属性包含了希望为树中每个项显示的内容(通常是文本)。如果显示非文本内容,最好使用TreeViewItem封装器,并通过TreeViewItem.Header属性提供内容,如果显示非UIElement对象,也可以通过HeaderTemplate属性的数据模板设置格式。

<TreeView ItemsSource="{Binding TreeItemsOrganization}" Style="{DynamicResource TreeViewStyleMain}"&nbsp;
    Background="White" BorderThickness="0"&nbsp;
    SelectedItemChanged="TreeView_SelectedItemChanged" >
&nbsp; &nbsp; <!--cm:Message.Attach="[Event SeletedItemChanged] = [Action SeletedItemChanged]"> -->
&nbsp; &nbsp; <TreeView.ItemContainerStyle>
&nbsp; &nbsp; &nbsp; &nbsp; <Style TargetType="{x:Type TreeViewItem}">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="IsExpanded" Value="{Binding Path=IsExpanded,Mode=TwoWay}" />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="IsSelected" Value="{Binding Path=IsSelected,Mode=TwoWay}"/>
&nbsp; &nbsp; &nbsp; &nbsp; </Style>
&nbsp; &nbsp; </TreeView.ItemContainerStyle>
&nbsp; &nbsp; <TreeView.Resources>
&nbsp; &nbsp; &nbsp; &nbsp; <HierarchicalDataTemplate DataType="{x:Type local:TreeItem}" ItemsSource="{Binding Path=Children,Mode=OneWay}" >
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <StackPanel x:Name="My_SP"&nbsp; Orientation="Horizontal" Margin="2">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Image VerticalAlignment="Center" Source="{Binding itemIcon}" />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <ContentPresenter&nbsp; Content="{Binding Path=Item,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Margin="2,0"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </StackPanel>
&nbsp; &nbsp; &nbsp; &nbsp; </HierarchicalDataTemplate>
&nbsp; &nbsp; </TreeView.Resources>
</TreeView>

上述代码中,通过HierarchicalDataTemplate来设置TreeView.ItemTemplate属性,而不是DataTemplate对象。前者能够封装第二个模板,然后HierarchicalDataTemplate就可以从第一层数据中提起项的集合,提供给第二层的模板:

更复杂一点的就是:

实际上,上述代码有两个模板,每个模板用于书控件中的每个层次。第二个模板使用从第一个模板中选择的项作为其数据源。

自定义控件的样式和模板:

<Style x:Key="ExpandCollapseToggleStyle" TargetType="ToggleButton">
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="Focusable" Value="False" />
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="Width" Value="16" />
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="Height" Value="16" />
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="Template">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Setter.Value>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <ControlTemplate TargetType="ToggleButton">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Border Width="16" Height="16" Padding="4" Background="Transparent">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Path x:Name="ExpandPath" Data="{StaticResource TreeArrow}" Fill="{Binding Foreground, RelativeSource={RelativeSource AncestorType=TreeViewItem}}" RenderTransformOrigin="0.5,0.5" Stretch="Uniform">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Path.RenderTransform>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <RotateTransform Angle="-90" />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </Path.RenderTransform>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </Path>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </Border>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <ControlTemplate.Triggers>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Trigger Property="IsChecked" Value="True">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Setter TargetName="ExpandPath" Property="RenderTransform">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Setter.Value>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <RotateTransform Angle="0" />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </Setter.Value>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </Setter>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </Trigger>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </ControlTemplate.Triggers>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </ControlTemplate>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </Setter.Value>
&nbsp; &nbsp; &nbsp; &nbsp; </Setter>
&nbsp; &nbsp; </Style>
&nbsp; &nbsp; <Style x:Key="TreeViewItemBaseStyle" BasedOn="{StaticResource BaseStyle}" TargetType="TreeViewItem">
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisualRadius0Margin0}" />
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="Background" Value="Transparent" />
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="Padding" Value="10,0" />
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="BorderThickness" Value="0" />
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="Template">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Setter.Value>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <ControlTemplate TargetType="TreeViewItem">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Grid>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Grid.RowDefinitions>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <RowDefinition MinHeight="{StaticResource DefaultControlHeight}" />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <RowDefinition />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </Grid.RowDefinitions>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Border
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; x:Name="Bd"
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Padding="{TemplateBinding Padding}"
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Background="{TemplateBinding Background}"
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; BorderBrush="{TemplateBinding BorderBrush}"
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; BorderThickness="{TemplateBinding BorderThickness}"
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius), RelativeSource={RelativeSource TemplatedParent}}"
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SnapsToDevicePixels="true">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <DockPanel Margin="{Binding Converter={StaticResource TreeViewItemMarginConverter}, RelativeSource={RelativeSource TemplatedParent}}" LastChildFill="True">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <ToggleButton x:Name="Expander" ClickMode="Press" IsChecked="{Binding IsExpanded, RelativeSource={RelativeSource TemplatedParent}}" Style="{StaticResource ExpandCollapseToggleStyle}" />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <ContentPresenter x:Name="PART_Header" VerticalAlignment="Center" ContentSource="Header" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </DockPanel>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </Border>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <ItemsPresenter x:Name="ItemsHost" Grid.Row="1" />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </Grid>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <ControlTemplate.Triggers>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Trigger SourceName="Bd" Property="IsMouseOver" Value="true">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Setter TargetName="Bd" Property="Background" Value="{DynamicResource SecondaryRegionBrush}" />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </Trigger>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Trigger Property="IsExpanded" Value="false">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Setter TargetName="ItemsHost" Property="Visibility" Value="Collapsed" />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </Trigger>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Trigger Property="HasItems" Value="false">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Setter TargetName="Expander" Property="Visibility" Value="Hidden" />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </Trigger>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Trigger Property="IsSelected" Value="true">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Setter TargetName="Bd" Property="Background" Value="{DynamicResource PrimaryBrush}" />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="Foreground" Value="{DynamicResource TextIconBrush}" />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </Trigger>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <MultiTrigger>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <MultiTrigger.Conditions>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Condition Property="IsSelected" Value="true" />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Condition Property="IsSelectionActive" Value="false" />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </MultiTrigger.Conditions>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Setter TargetName="Bd" Property="Background" Value="{DynamicResource DarkDefaultBrush}" />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}" />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </MultiTrigger>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Trigger Property="IsEnabled" Value="false">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="Foreground" Value="{StaticResource {x:Static SystemColors.GrayTextBrushKey}}" />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </Trigger>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </ControlTemplate.Triggers>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </ControlTemplate>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </Setter.Value>
&nbsp; &nbsp; &nbsp; &nbsp; </Setter>
&nbsp; &nbsp; </Style>
&nbsp; &nbsp; <Style x:Key="TreeViewBaseStyle" BasedOn="{StaticResource BaseStyle}" TargetType="TreeView">
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="Focusable" Value="False" />
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="Background" Value="{DynamicResource RegionBrush}" />
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="BorderBrush" Value="{DynamicResource BorderBrush}" />
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="BorderThickness" Value="1" />
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="Padding" Value="0" />
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto" />
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" />
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="ScrollViewer.PanningMode" Value="Both" />
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="hc:ScrollViewer.IsInertiaEnabled" Value="False" />
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="Stylus.IsFlicksEnabled" Value="False" />
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="VerticalContentAlignment" Value="Center" />
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="VirtualizingPanel.IsVirtualizing" Value="True" />
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="Template">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Setter.Value>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <ControlTemplate TargetType="TreeView">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Border x:Name="Bd" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" SnapsToDevicePixels="true">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <hc:ToggleBlock HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" IsChecked="{Binding HasItems, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <hc:ToggleBlock.CheckedContent>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <hc:ScrollViewer
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; x:Name="_tv_scrollviewer_"
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Padding="{TemplateBinding Padding}"
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Background="{TemplateBinding Background}"
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CanContentScroll="false"
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Focusable="false"
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}"
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; IsInertiaEnabled="{Binding Path=(hc:ScrollViewer.IsInertiaEnabled), RelativeSource={RelativeSource TemplatedParent}}"
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Template="{StaticResource ScrollViewerBaseControlTemplate}"
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <ItemsPresenter />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </hc:ScrollViewer>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </hc:ToggleBlock.CheckedContent>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <hc:ToggleBlock.UnCheckedContent>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <hc:Empty />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </hc:ToggleBlock.UnCheckedContent>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </hc:ToggleBlock>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </Border>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <ControlTemplate.Triggers>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Trigger Property="IsEnabled" Value="false">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Setter TargetName="Bd" Property="Background" Value="{StaticResource {x:Static SystemColors.ControlBrushKey}}" />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </Trigger>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Trigger Property="VirtualizingPanel.IsVirtualizing" Value="true">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Setter TargetName="_tv_scrollviewer_" Property="CanContentScroll" Value="true" />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </Trigger>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </ControlTemplate.Triggers>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </ControlTemplate>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </Setter.Value>
&nbsp; &nbsp; &nbsp; &nbsp; </Setter>
&nbsp; &nbsp; &nbsp; &nbsp; <Style.Triggers>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Trigger Property="VirtualizingPanel.IsVirtualizing" Value="true">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="ItemsPanel">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Setter.Value>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <ItemsPanelTemplate>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <VirtualizingStackPanel />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </ItemsPanelTemplate>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </Setter.Value>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </Setter>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </Trigger>
&nbsp; &nbsp; &nbsp; &nbsp; </Style.Triggers>
&nbsp; &nbsp; </Style>

DataGrid控件

DataGrid是最完备的数据显示工具。他将数据分割到包含行列的网格中,就想ListView控件,但是DataGrid控件具有其他格式化特性(如:冻结列、设置单行样式),并且支持就地编辑数据。DataGrid控件从对象集合获取信息并在具有行和单元格的网络中显示信息。每行和单独的对象相对应,并且每列和对象的某个属性相对应。其选择模型允许选择一行、多行或者一些单元格的组合。

为创建暂时应急的DataGrid控件,可使用自动列生成功能:

AutoGenerateColumns=true

DataGrid的基本显示属性:

名称

说明

RowBackground
AlternatingRowBackground

用于绘制每行北京的画刷,并且决定是否使用不同的背景颜色绘制交替行,从而更容易区分行

ColumnHeaderHeight

位于DataGrid控件顶部的列标题行的高度

RowHeaderWidth

具有行题头的列的宽度。该列在网格的最左边,不显示任何数据。该列使用箭头指示当前选择的行,使用圈住的箭头指示正在编辑的行

ColumnWidth

DataGridLength对象,用于设置每列默认宽度的尺寸改变模式

RowHeight

每行的高度。如果准备在DataGrid控件中显示多行文本或者不同的内容(图像等),该设置很有用。与列不同,用户不能改变行的尺寸

GridLinesVisibility

确定是否显示网格线的DataGridGridLines枚举值

VerticalGridLinesBrush

用于绘制列之间网格线的画刷

HorizontalGridLinesBrush

用于绘制行之间网格线的画刷

HeadersVisibity

确定显示哪个题头的DataGrisHeaders枚举值

HorizontalScrollBarVisibility
VerticalScrollBarVisibility

去顶是否显示滚动条的枚举值。默认是Auto(当需要时显示)

改变列的尺寸与重新安排列

当显示自动生成的列时,DataGrid控件尝试根据DataGrid.ColumnWidth属性智能地改变每列的宽度。

为设置ColumnWidth属性,需要提供DataGridLength对象。DataGridLength对象能够指定确切的尺寸或者指定特定的尺寸改变模式,从而让DataGrid控件自动完成。

grid.ColumnWidth=new DataGridLength(150);

使用足够的列宽来适应他们的题头文本:

grid.ColumnWidth=DataGridLength.SizeToHeader;

加宽每一列以适应当前视图中最宽的值:

grid.ColumnWidth=DataGridLength.SizeToCells;

加宽每一列以适应最大的显示值或者题头文本,使用其中的最大值:

grid.ColumnWidth=DataGridLength.Auto;

通常,用户能够通过将列边缘拖动到任意位置来改变列的尺寸。可通过将CanUserResizeColumns属性设置为false来阻止这一行为。也可以将列的CanUserResize属性设置为false,阻止用户改变特定列的尺寸。通过CanUserReorderColumns属性或者特定列的CanUserReorder属性设置为false来阻止用户改变列的位置。

定义列

将AutoGenerateColumns属性设置为false以关闭自动列生成功能。然后可以使用希望的设置和指定的顺序,明确地定义希望使用的列。使用合适的列对象来填充DataGrid.Columns集合。

  • DataGridTextColumn:这种列对于大部分数据类型时标准选择,值转换成文本
  • DataGridCheckBoxColumn:列显示复选框。通常是只读的,当编辑行时,会成为普通的复选框
  • DataGridHyperlinkColumn:显示单击的链接
  • DataGridComboBox:这种列最初和DataGridTextColumn类似,在编辑模式下,就编程可以下拉的ComboBox控件
  • DataGridTemplateColumn:这种列允许显示值定义数据模板。

设置列的格式和样式

可使用设置TextBlock格式相同的方式设置DataGridTextColumn格式,但是无法设置多行显示,需要使用ElementStyle属性了设置,使用具有多行显示的TextBlock样式即可。

属性

说明

ColumnHeaderStyle

位于网格顶部的列题头的TextBlock

RowHeaderStyle

行题头的TextBlock。一般用复选框做控件模板

DragIndicatorStyle

当用户正在将列题头拖动到新位置时用于列题头的TextBlock

RowStyle

用于普通行的TextBlock(没有通过列的ElementStyle属性明确定制过的行)

设置行的格式

DataGrid.LoadingRow事件:当每一行出现在屏幕上时,都会触发LoadingRow事件。当用户在网格中滚动是,会连续触发事件,所以不能在事件中进行耗时的处理。

显示行细节

DataGrid支持行细节(row details),一块可选的独立显示区域,在行的列值下面显示。

  • 能够跨越DataGrid控件的整个宽度,并且不会切入到独立的列中,从而提供了更过可供使用的空间
  • 可配置行细节区域,从而只为选择的行显示该区域,当不需要时,允许用户折叠额外的细节

可以通过设置属性DataGrid.RowDetailsTemplate属性,来定义行细节区域显示的内容。

可以通过设置DataGrid.0RowDetailsVisibilityMode属性来设置行细节区域的显示行为,默认是VisibleWhenSelected。

冻结列

冻结列位于DataGrid 控件的左边,甚至当向右滚动时,冻结列任然在左边。对于非常宽的网格,冻结列非常的有用,可以保持某些信息始终可见。通过属性FrozenColumnCount属性设置大于0的数。

冻结列必须总是位于网格的左侧,如果是1列,则就是最左边的那列,如果是2列,那就是最左边的两列。

选择

和普通的列表控件类似,DataGrid允许用户选择单个项,并且响应SelectionChanged事件。可以使用SelectedItem属性来找到当前选中的项。可以通过SelectionMode属性来设置单选还是多选。为了选择多行,用户必须按下Shift或者Ctrl键。通常我们可以在RowHeader中放置CheckBox来显示哪行被选中,也可以通过CheckBox直接选中某行或者多行。

排序

可以通过单击列题头来实现列的排序,可以通过设置SortMemberPath属性从绑定的数据对象中选择不同的属性来排序。可以通过CanUserSortColumns属性或者特定列的CanUserSort属性设置为false来禁止排序功能

编辑

一般情况下,DataGrid多数用于数据展示,编辑的话比较少用,可以通过属性DataGrid.IsReadOnly或者DataGridColumn.IsReadOnly属性设置为false来禁用编辑功能。

列举一个DataGrid的样式:

<Style x:Key="RowHeaderGripperStyle" TargetType="Thumb">
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="Height" Value="8"/>
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="Background" Value="Transparent"/>
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="Cursor" Value="SizeNS"/>
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="Template">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Setter.Value>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <ControlTemplate TargetType="Thumb">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Border Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </ControlTemplate>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </Setter.Value>
&nbsp; &nbsp; &nbsp; &nbsp; </Setter>
&nbsp; &nbsp; </Style>
&nbsp; &nbsp; <Style x:Key="DataGridCellStyle" TargetType="DataGridCell">
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="FocusVisualStyle">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Setter.Value>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Style>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="Control.Template">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Setter.Value>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <ControlTemplate>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Rectangle Margin="2" Opacity=".6" SnapsToDevicePixels="true" Stroke="{DynamicResource SecondaryBorderBrush}" StrokeThickness="2" StrokeDashArray="1 1" RadiusX="4" RadiusY="4"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </ControlTemplate>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </Setter.Value>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </Setter>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </Style>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </Setter.Value>
&nbsp; &nbsp; &nbsp; &nbsp; </Setter>
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="Background" Value="Transparent"/>
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="BorderBrush" Value="Transparent"/>
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="BorderThickness" Value="0"/>
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="VerticalContentAlignment" Value="Center"/>
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="HorizontalContentAlignment" Value="Left"/>
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="Padding" Value="{StaticResource DefaultControlPadding}"/>
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="hc:BorderElement.CornerRadius" Value="{StaticResource DefaultCornerRadius}"/>
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="Template">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Setter.Value>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <ControlTemplate TargetType="DataGridCell">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Border Background="Transparent">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Border Margin="0,0,4,0"&nbsp; CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent}}" Padding="{TemplateBinding Padding}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" SnapsToDevicePixels="True">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </Border>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </Border>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </ControlTemplate>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </Setter.Value>
&nbsp; &nbsp; &nbsp; &nbsp; </Setter>
&nbsp; &nbsp; &nbsp; &nbsp; <Style.Triggers>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <MultiDataTrigger>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <MultiDataTrigger.Conditions>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Condition Binding="{Binding IsSelected,RelativeSource={RelativeSource Self}}" Value="true"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Condition Binding="{Binding SelectionUnit,RelativeSource={RelativeSource FindAncestor,AncestorType=DataGrid}}" Value="Cell"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </MultiDataTrigger.Conditions>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="Foreground" Value="{DynamicResource TextIconBrush}"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="Background" Value="{DynamicResource PrimaryBrush}"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </MultiDataTrigger>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <MultiDataTrigger>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <MultiDataTrigger.Conditions>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Condition Binding="{Binding IsSelected,RelativeSource={RelativeSource Self}}" Value="true"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Condition Binding="{Binding IsSelected,RelativeSource={RelativeSource AncestorType=DataGridRow}}" Value="False"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Condition Binding="{Binding SelectionUnit,RelativeSource={RelativeSource FindAncestor,AncestorType=DataGrid}}" Value="CellOrRowHeader"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </MultiDataTrigger.Conditions>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="Foreground" Value="{DynamicResource TextIconBrush}"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="Background" Value="{DynamicResource PrimaryBrush}"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </MultiDataTrigger>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <MultiDataTrigger>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <MultiDataTrigger.Conditions>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Condition Binding="{Binding IsSelected,RelativeSource={RelativeSource Self}}" Value="true"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Condition Binding="{Binding IsSelected,RelativeSource={RelativeSource AncestorType=DataGridRow}}" Value="True"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Condition Binding="{Binding SelectionUnit,RelativeSource={RelativeSource FindAncestor,AncestorType=DataGrid}}" Value="CellOrRowHeader"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </MultiDataTrigger.Conditions>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="Foreground" Value="{DynamicResource TextIconBrush}"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </MultiDataTrigger>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <MultiDataTrigger>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <MultiDataTrigger.Conditions>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Condition Binding="{Binding IsSelected,RelativeSource={RelativeSource Self}}" Value="true"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Condition Binding="{Binding SelectionUnit,RelativeSource={RelativeSource FindAncestor,AncestorType=DataGrid}}" Value="FullRow"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </MultiDataTrigger.Conditions>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="Foreground" Value="{DynamicResource TextIconBrush}"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </MultiDataTrigger>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <MultiTrigger>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <MultiTrigger.Conditions>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Condition Property="IsSelected" Value="true"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Condition Property="Selector.IsSelectionActive" Value="false"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </MultiTrigger.Conditions>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="Background" Value="{DynamicResource DarkDefaultBrush}"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </MultiTrigger>
&nbsp; &nbsp; &nbsp; &nbsp; </Style.Triggers>
&nbsp; &nbsp; </Style>
&nbsp; &nbsp; <Style x:Key="DataGridRowStyle" TargetType="DataGridRow">
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="Background" Value="{DynamicResource RegionBrush}"/>
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"/>
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="SnapsToDevicePixels" Value="true"/>
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="Margin" Value="0,0,0,4"/>
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="Padding" Value="0,6"/>
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="MinHeight" Value="44"/>
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="Validation.ErrorTemplate" Value="{x:Null}"/>
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="ValidationErrorTemplate">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Setter.Value>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <ControlTemplate>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <TextBlock Foreground="Red" Margin="2,0,0,0" Text="!" VerticalAlignment="Center"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </ControlTemplate>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </Setter.Value>
&nbsp; &nbsp; &nbsp; &nbsp; </Setter>
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="Template">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Setter.Value>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <ControlTemplate TargetType="DataGridRow">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <SelectiveScrollingGrid>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <SelectiveScrollingGrid.ColumnDefinitions>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <ColumnDefinition Width="Auto"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <ColumnDefinition Width="*"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </SelectiveScrollingGrid.ColumnDefinitions>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <SelectiveScrollingGrid.RowDefinitions>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <RowDefinition Height="*"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <RowDefinition Height="Auto"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </SelectiveScrollingGrid.RowDefinitions>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Border CornerRadius="4" Grid.ColumnSpan="2" x:Name="DGR_Border" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" SnapsToDevicePixels="True"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <DataGridCellsPresenter MinHeight="{TemplateBinding MinHeight}" VerticalContentAlignment="Center" Grid.Row="0" Grid.Column="1" ItemsPanel="{TemplateBinding ItemsPanel}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <DataGridDetailsPresenter Margin="0,6" Grid.Column="1" Grid.Row="1" SelectiveScrollingGrid.SelectiveScrollingOrientation="{Binding AreRowDetailsFrozen, ConverterParameter={x:Static SelectiveScrollingOrientation.Vertical}, Converter={x:Static DataGrid.RowDetailsScrollingConverter}, RelativeSource={RelativeSource AncestorType=DataGrid}}" Visibility="{TemplateBinding DetailsVisibility}"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <DataGridRowHeader Grid.Row="0" Grid.Column="0" SelectiveScrollingGrid.SelectiveScrollingOrientation="Vertical" Visibility="{Binding HeadersVisibility, ConverterParameter={x:Static DataGridHeadersVisibility.Row}, Converter={x:Static DataGrid.HeadersVisibilityConverter}, RelativeSource={RelativeSource AncestorType=DataGrid}}"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </SelectiveScrollingGrid>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </ControlTemplate>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </Setter.Value>
&nbsp; &nbsp; &nbsp; &nbsp; </Setter>
&nbsp; &nbsp; &nbsp; &nbsp; <Style.Triggers>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Trigger Property="IsMouseOver" Value="true">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="Background" Value="{DynamicResource DarkDefaultBrush}"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </Trigger>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Trigger Property="IsSelected" Value="True">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="Background" Value="{DynamicResource PrimaryBrush}"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="TextElement.Foreground" Value="{DynamicResource TextIconBrush}"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </Trigger>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <MultiTrigger>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <MultiTrigger.Conditions>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Condition Property="IsSelected" Value="true"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Condition Property="Selector.IsSelectionActive" Value="false"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </MultiTrigger.Conditions>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="Background" Value="{DynamicResource DarkDefaultBrush}"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </MultiTrigger>
&nbsp; &nbsp; &nbsp; &nbsp; </Style.Triggers>
&nbsp; &nbsp; </Style>
&nbsp; &nbsp; <Style x:Key="ColumnHeaderGripperStyle" TargetType="Thumb">
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="Width" Value="8"/>
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="Background" Value="Transparent"/>
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="Cursor" Value="SizeWE"/>
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="Template">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Setter.Value>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <ControlTemplate TargetType="Thumb">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Border Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </ControlTemplate>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </Setter.Value>
&nbsp; &nbsp; &nbsp; &nbsp; </Setter>
&nbsp; &nbsp; </Style>
&nbsp; &nbsp; <Style x:Key="DataGridColumnHeaderStyle" TargetType="DataGridColumnHeader">
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="VerticalContentAlignment" Value="Center"/>
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"/>
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="Padding" Value="12,6,12,12"/>
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="MinHeight" Value="44"/>
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="Template">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Setter.Value>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <ControlTemplate TargetType="DataGridColumnHeader">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <hc:SimplePanel>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="Transparent" Padding="{TemplateBinding Padding}">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Grid HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Grid.ColumnDefinitions>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <ColumnDefinition/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <ColumnDefinition Width="Auto"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </Grid.ColumnDefinitions>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <ContentPresenter RecognizesAccessKey="True" VerticalAlignment="Center" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <ToggleButton Grid.Column="1" VerticalAlignment="Center" Height="{x:Static system:Double.NaN}" Padding="4,0" Width="20" IsEnabled="False" Opacity="1" Foreground="{DynamicResource PrimaryBrush}" x:Name="ToggleButtonSortDirection" Style="{StaticResource ToggleButtonIconTransparent}" hc:IconSwitchElement.Geometry="{StaticResource DownGeometry}" hc:IconSwitchElement.GeometrySelected="{StaticResource UpGeometry}"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </Grid>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </Border>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Thumb x:Name="PART_LeftHeaderGripper" HorizontalAlignment="Left" Style="{StaticResource ColumnHeaderGripperStyle}"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Thumb x:Name="PART_RightHeaderGripper" HorizontalAlignment="Right" Style="{StaticResource ColumnHeaderGripperStyle}"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </hc:SimplePanel>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <ControlTemplate.Triggers>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Trigger Property="SortDirection" Value="{x:Null}">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="Visibility" Value="Collapsed" TargetName="ToggleButtonSortDirection"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </Trigger>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Trigger Property="SortDirection" Value="Ascending">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="IsChecked" Value="True" TargetName="ToggleButtonSortDirection"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </Trigger>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Trigger Property="SortDirection" Value="Descending">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="IsChecked" Value="False" TargetName="ToggleButtonSortDirection"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </Trigger>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </ControlTemplate.Triggers>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </ControlTemplate>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </Setter.Value>
&nbsp; &nbsp; &nbsp; &nbsp; </Setter>
&nbsp; &nbsp; &nbsp; &nbsp; <Style.Triggers>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Trigger Property="SortDirection" Value="Ascending">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="Foreground" Value="{DynamicResource PrimaryBrush}"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </Trigger>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Trigger Property="SortDirection" Value="Descending">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="Foreground" Value="{DynamicResource PrimaryBrush}"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="Foreground" Value="{DynamicResource PrimaryBrush}"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </Trigger>
&nbsp; &nbsp; &nbsp; &nbsp; </Style.Triggers>
&nbsp; &nbsp; </Style>
&nbsp; &nbsp; <Style x:Key="DataGridRowHeaderStyle" TargetType="DataGridRowHeader">
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="Template">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Setter.Value>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <ControlTemplate TargetType="DataGridRowHeader">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <hc:SimplePanel HorizontalAlignment="Center">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="Transparent" Padding="{TemplateBinding Padding}" >
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <StackPanel Orientation="Horizontal">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <ContentPresenter RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="Center"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </StackPanel>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </Border>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Thumb x:Name="PART_TopHeaderGripper" Style="{StaticResource RowHeaderGripperStyle}" VerticalAlignment="Top"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Thumb x:Name="PART_BottomHeaderGripper" Style="{StaticResource RowHeaderGripperStyle}" VerticalAlignment="Bottom"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </hc:SimplePanel>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </ControlTemplate>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </Setter.Value>
&nbsp; &nbsp; &nbsp; &nbsp; </Setter>
&nbsp; &nbsp; </Style>
&nbsp; &nbsp; <Style x:Key="TextBlockComboBoxStyle" TargetType="ComboBox">
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="Focusable" Value="True"/>
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="Template">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Setter.Value>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <ControlTemplate TargetType="ComboBox">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <TextBlock IsHitTestVisible="False" Text="{TemplateBinding Text}" TextTrimming="CharacterEllipsis"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </ControlTemplate>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </Setter.Value>
&nbsp; &nbsp; &nbsp; &nbsp; </Setter>
&nbsp; &nbsp; </Style>
&nbsp; &nbsp; <Style x:Key="DataGridTextColumnStyle" TargetType="TextBlock">
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="TextTrimming" Value="CharacterEllipsis"/>
&nbsp; &nbsp; </Style>
&nbsp; &nbsp; <Style TargetType="DataGrid">
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="Background" Value="{DynamicResource SecondaryRegionBrush}"/>
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="BorderBrush" Value="{DynamicResource BorderBrush}"/>
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="BorderThickness" Value="0"/>
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="GridLinesVisibility" Value="None"/>
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="RowDetailsVisibilityMode" Value="VisibleWhenSelected"/>
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="ScrollViewer.CanContentScroll" Value="true"/>
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="ScrollViewer.PanningMode" Value="Both"/>
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="EnableRowVirtualization" Value="True"/>
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="CanUserAddRows" Value="False"/>
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="CanUserDeleteRows" Value="False"/>
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="CanUserReorderColumns" Value="False"/>
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="CanUserResizeRows" Value="False"/>
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="ColumnHeaderStyle" Value="{StaticResource DataGridColumnHeaderStyle}"/>
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="RowHeaderStyle" Value="{StaticResource DataGridRowHeaderStyle}"/>
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="RowStyle" Value="{StaticResource DataGridRowStyle}"/>
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="CellStyle" Value="{StaticResource DataGridCellStyle}"/>
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="Padding" Value="6"/>
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="ColumnWidth" Value="*"/>
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="hc:DataGridAttach.TextColumnStyle" Value="{StaticResource DataGridTextColumnStyle}"/>
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="hc:DataGridAttach.EditingTextColumnStyle" Value="{StaticResource TextBoxBaseStyle}"/>
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="hc:DataGridAttach.ComboBoxColumnStyle" Value="{StaticResource TextBlockComboBoxStyle}"/>
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="hc:DataGridAttach.EditingComboBoxColumnStyle" Value="{StaticResource ComboBoxBaseStyle}"/>
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="hc:DataGridAttach.CheckBoxColumnStyle" Value="{StaticResource CheckBoxBaseStyle}"/>
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="hc:DataGridAttach.EditingCheckBoxColumnStyle" Value="{StaticResource CheckBoxBaseStyle}"/>
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="hc:DataGridAttach.ApplyDefaultStyle" Value="True"/>
&nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="Template">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Setter.Value>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <ControlTemplate TargetType="DataGrid">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <ControlTemplate.Resources>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Storyboard x:Key="Storyboard1">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="PART_VerticalScrollBar">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <EasingDoubleKeyFrame KeyTime="0:0:.2" Value=".8"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </DoubleAnimationUsingKeyFrames>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="PART_HorizontalScrollBar">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <EasingDoubleKeyFrame KeyTime="0:0:.2" Value=".8"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </DoubleAnimationUsingKeyFrames>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </Storyboard>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Storyboard x:Key="Storyboard2">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="PART_VerticalScrollBar">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <EasingDoubleKeyFrame KeyTime="0:0:.2" Value="0"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </DoubleAnimationUsingKeyFrames>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="PART_HorizontalScrollBar">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <EasingDoubleKeyFrame KeyTime="0:0:.2" Value="0"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </DoubleAnimationUsingKeyFrames>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </Storyboard>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </ControlTemplate.Resources>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="True">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <hc:ToggleBlock IsChecked="{Binding HasItems,RelativeSource={RelativeSource TemplatedParent},Mode=OneWay}" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <hc:ToggleBlock.CheckedContent>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <ScrollViewer x:Name="DG_ScrollViewer" Focusable="false">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <ScrollViewer.Template>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <ControlTemplate TargetType="ScrollViewer">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Grid>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Grid.ColumnDefinitions>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <ColumnDefinition Width="Auto"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <ColumnDefinition Width="*"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <ColumnDefinition Width="Auto"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </Grid.ColumnDefinitions>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Grid.RowDefinitions>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <RowDefinition Height="Auto"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <RowDefinition Height="*"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </Grid.RowDefinitions>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Button Command="{x:Static DataGrid.SelectAllCommand}" Margin="0,0,0,6" Visibility="{Binding HeadersVisibility, ConverterParameter={x:Static DataGridHeadersVisibility.All}, Converter={x:Static DataGrid.HeadersVisibilityConverter}, RelativeSource={RelativeSource AncestorType=DataGrid}}" Width="{Binding CellsPanelHorizontalOffset, RelativeSource={RelativeSource AncestorType=DataGrid},Converter={StaticResource DoubleMinConverter}}" Style="{StaticResource ButtonIcon}" hc:IconElement.Geometry="{StaticResource AllGeometry}" Foreground="{DynamicResource PrimaryBrush}"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <DataGridColumnHeadersPresenter x:Name="PART_ColumnHeadersPresenter" Grid.ColumnSpan="2" Grid.Row="0" Grid.Column="1" Visibility="{Binding HeadersVisibility, ConverterParameter={x:Static DataGridHeadersVisibility.Column}, Converter={x:Static DataGrid.HeadersVisibilityConverter}, RelativeSource={RelativeSource AncestorType=DataGrid}}"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <ScrollContentPresenter x:Name="PART_ScrollContentPresenter" CanContentScroll="{TemplateBinding CanContentScroll}" Grid.ColumnSpan="3" Grid.Column="0" Grid.Row="1"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <ScrollBar Style="{StaticResource ScrollBarBaseStyle}" Opacity="0" x:Name="PART_VerticalScrollBar" Grid.Column="2" Maximum="{TemplateBinding ScrollableHeight}" Orientation="Vertical" Grid.Row="1" Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" Value="{Binding VerticalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" ViewportSize="{TemplateBinding ViewportHeight}"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <ScrollBar Style="{StaticResource ScrollBarBaseStyle}" Opacity="0" x:Name="PART_HorizontalScrollBar" Grid.Column="1" Maximum="{TemplateBinding ScrollableWidth}" Orientation="Horizontal" VerticalAlignment="Bottom" Grid.Row="1" Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}" Value="{Binding HorizontalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" ViewportSize="{TemplateBinding ViewportWidth}"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </Grid>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <ControlTemplate.Triggers>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <EventTrigger RoutedEvent="MouseEnter">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <BeginStoryboard Storyboard="{StaticResource Storyboard1}"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </EventTrigger>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <EventTrigger RoutedEvent="MouseLeave">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <BeginStoryboard Storyboard="{StaticResource Storyboard2}"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </EventTrigger>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </ControlTemplate.Triggers>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </ControlTemplate>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </ScrollViewer.Template>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </ScrollViewer>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </hc:ToggleBlock.CheckedContent>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <hc:ToggleBlock.UnCheckedContent>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <hc:Empty />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </hc:ToggleBlock.UnCheckedContent>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </hc:ToggleBlock>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </Border>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </ControlTemplate>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </Setter.Value>
&nbsp; &nbsp; &nbsp; &nbsp; </Setter>
&nbsp; &nbsp; &nbsp; &nbsp; <Style.Triggers>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <MultiTrigger>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <MultiTrigger.Conditions>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Condition Property="IsGrouping" Value="true"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Condition Property="VirtualizingPanel.IsVirtualizingWhenGrouping" Value="false"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </MultiTrigger.Conditions>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </MultiTrigger>
&nbsp; &nbsp; &nbsp; &nbsp; </Style.Triggers>
&nbsp; &nbsp; </Style>