Я использовал пользовательский элемент управления сеткой данных, который добавляет TextBox к заголовкам столбцов для фильтрации.К сожалению, я столкнулся с проблемой, когда пытался привязать свойство Visiblilty DataGridRow к свойству Text TextBox (называемое filterTextBox);см. ниже код.Объект, полученный в методе преобразователя "SearchColumnToVisibilityConverter", имеет значение "DependencyProperty.UnsetValue".
<ControlTemplate TargetType="{x:Type local:SimpuDataGrid}">
<Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
<StackPanel Orientation="Vertical" DataContext="{TemplateBinding DataContext}">
<TextBox Width="200" Margin="2" HorizontalAlignment="Left" x:Name="txtFullTextSearch"
Visibility="{TemplateBinding EnableFullTextSearch,
Converter={StaticResource BooleanToVisibilityConverter}}" />
<DataGrid x:Name="simpuGrid"
ItemsSource="{TemplateBinding ItemsSource}" CanUserAddRows="{TemplateBinding CanUserAddRows}"
CanUserDeleteRows="{TemplateBinding CanUserDeleteRows}"
AutoGenerateColumns="{TemplateBinding AutoGenerateColumns}">
<DataGrid.Resources>
<!--Custom Column Header template to show extra elements in the header-->
<Style TargetType="{x:Type DataGridColumnHeader}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type DataGridColumnHeader}">
<!--Let's keep the top section grid to contain the DataGridHeaderBorder, and left+right thumbs.-->
<Grid x:Name="fullHeader" Background="{StaticResource normalBrushBack}">
<!--Here is the theme based DataGridHeaderBorder. I've used Aero here.-->
<aero:DataGridHeaderBorder x:Name='HeaderBorder' SortDirection="{TemplateBinding SortDirection}" IsHovered="{TemplateBinding IsMouseOver}" IsPressed="{TemplateBinding IsPressed}" IsClickable="{TemplateBinding CanUserSort}" BorderThickness="0,0,1,1" BorderBrush="{TemplateBinding Foreground}" Background="Transparent" SeparatorVisibility="{TemplateBinding SeparatorVisibility}" SeparatorBrush="#FFC9CACA">
<!--We will put 3 elements inside the border: Content of header, a drop down button, and a sort order indicator.-->
<Grid Margin="0,0,0,0">
<Grid.RowDefinitions>
<!--For ContentPresenter-->
<RowDefinition Height="*" />
<!--For drop down button-->
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<!--For ContentPresenter-->
<ColumnDefinition Width="*" />
<!--For sort order indicator-->
<ColumnDefinition Width="12" />
</Grid.ColumnDefinitions>
<!--Content of the header.-->
<ContentPresenter Grid.Row="0" Grid.Column="0" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" Cursor="{TemplateBinding Cursor}" >
<ContentPresenter.Content>
<MultiBinding Converter="{StaticResource headerConverter}">
<MultiBinding.Bindings>
<Binding ElementName="filterTextBox" Path="Text" />
<Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Content" />
</MultiBinding.Bindings>
</MultiBinding>
</ContentPresenter.Content>
</ContentPresenter>
<!--A textbox filter-->
<TextBox x:Name="filterTextBox" Background="White" Grid.Row="1" Grid.ColumnSpan="2" />
<!--A sort order arrow icon.-->
<Path x:Name="SortArrow" Grid.Row="0" Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Center" Width="8" RenderTransformOrigin=".5,.5" Visibility="Visible" Fill="{TemplateBinding Foreground}" Stretch="Uniform" Data="F1 M -5.215,6.099L 5.215,6.099L 0,0L -5.215,6.099 Z" />
</Grid>
</aero:DataGridHeaderBorder>
<Thumb x:Name="PART_LeftHeaderGripper" HorizontalAlignment="Left" Style="{StaticResource ColumnHeaderGripperStyle}" />
<Thumb x:Name="PART_RightHeaderGripper" HorizontalAlignment="Right" Style="{StaticResource ColumnHeaderGripperStyle}" />
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="SortDirection" Value="Descending">
<Setter TargetName="SortArrow" Property="RenderTransform">
<Setter.Value>
<RotateTransform Angle="180" />
</Setter.Value>
</Setter>
</Trigger>
<Trigger Property='IsMouseOver' SourceName="fullHeader" Value='True'>
<Trigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation BeginTime="00:00:00" Duration="00:00:00.20000"
Storyboard.TargetName="HoverRectangle"
Storyboard.TargetProperty="(UIElement.Opacity)"
To='1.0' />
</Storyboard>
</BeginStoryboard>
</Trigger.EnterActions>
<Trigger.ExitActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation BeginTime="00:00:00" Duration="00:00:00.20000"
Storyboard.TargetName="HoverRectangle"
Storyboard.TargetProperty="(UIElement.Opacity)"
To='0' />
</Storyboard>
</BeginStoryboard>
</Trigger.ExitActions>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!--End of custom DataGridColumnHeader template-->
</DataGrid.Resources>
<DataGrid.ItemContainerStyle>
<Style TargetType="{x:Type DataGridRow}">
<Setter Property="Visibility">
<Setter.Value>
<MultiBinding Converter="{StaticResource SearchColumnToVisibilityConverter}">
<Binding ElementName="filterTextBox" Path="Text"/>
<Binding BindsDirectlyToSource="True"/>
</MultiBinding>
</Setter.Value>
</Setter>
</Style>
</DataGrid.ItemContainerStyle>
</DataGrid>
</StackPanel>
</Border>
</ControlTemplate>
Я надеюсь, что кто-то может мне помочь!
Спасибо