filter value cannot be bound

Grids for WPF Forum

Posted 3 months ago by yejianbiao
Version: 23.1.4
Avatar

Why can't I bind data to Value in StringFilterBase

Comments (2)

Posted 3 months ago by yejianbiao
Avatar

<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>

Posted 3 months ago by Actipro Software Support - Cleveland, OH, USA
Avatar

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}"


Actipro Software Support

The latest build of this product (v24.1.2) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.