Why can't I bind data to Value in StringFilterBase
Why can't I bind data to Value in StringFilterBase
<Grid VerticalAlignment="Stretch">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBox x:Name="txtBox"
/>
<grids:TreeListView RootItem="{Binding NodeRoot}"
ScrollViewer.CanContentScroll="True"
VirtualizingStackPanel.IsVirtualizing="True"
VirtualizingStackPanel.VirtualizationMode="Recycling"
IsDefaultColumnHeaderContextMenuEnabled="False"
CanColumnsResize="False"
MultiDragKind="SameDepth"
IsFilterActive="True"
Grid.Row="1" >
<grids:TreeListView.ItemAdapter>
<local:DefaultTreeListBoxItemAdapter ChildrenQueryModeDefault="OnExpansion" />
</grids:TreeListView.ItemAdapter>
<grids:TreeListView.DataFilter>
<local:TreeNodeFilter x:Name="filter"
Value="{Binding ElementName=txtBox,Path=Text,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" />
</grids:TreeListView.DataFilter>
<grids:TreeListView.Columns>
<grids:TreeListViewColumn Header="Label">
<DataTemplate>
<TextBlock Text="{Binding Name}"/>
</DataTemplate>
</grids:TreeListViewColumn>
</grids:TreeListView.Columns>
</grids:TreeListView>
</Grid>
Hello,
I think the problem here is that since DataFilterBase is a DependencyObject and not a WPF element, WPF's binding system doesn't know how to find the governing FrameworkElement. In our PropertyGridFiltersBuiltin QuickStart, as a workaround, we give our filter an x:Name and then use x:Reference in a binding on the TextBox-like control, similar to this:
Text="{Binding Source={x:Reference stringFilter}, Path=Value, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, Delay=500}"
Please log in to a validated account to post comments.