I have done this in a Winform application, and understand how that is done, but in WPF, I don't have a binding source instead I have a DataTable/DataView with a {Binding Column} in the XAML file.
So when I come to filter the Listbox I am struggling a little - either getting a syntax error or simply nothing is happening when I type.
Code for populating:
This works fine, and with the XAML below, I have two list boxes, linked as I wanted them to be, and when I double click on an entry in one list box the other textbox populates with the selected item from the other list...which is perfect.
XAML:
The projList is exactly the same.
I was attempting to filter with:
I have tried a lot of variations of this, based on the MSDN site (though I find that quite lacking on this particular issue - having a single example of "Code < 3", and various other tutorial sites - I can't see why it is not working.
I feel like I am missing something, like refreshing the codeList after the filter so that the filter takes effect, but every tutorial I have seen omits this as if it is not necessary and should happen automatically, so a little lost on why nothing is happening.
So when I come to filter the Listbox I am struggling a little - either getting a syntax error or simply nothing is happening when I type.
Code for populating:
C#:
System.Data.DataTable table = new System.Data.DataTable();
C#:
DataColumn codeColumn = new DataColumn("Code", typeof(string));
DataColumn projColumn = new DataColumn("Project", typeof(string));
dr = cmd.ExecuteReader();
table.Columns.Add(codeColumn);
table.Columns.Add(projColumn);
table.Load(dr);
DataView view = new DataView(table);
codeList.ItemsSource = view;
projList.ItemsSource = view;
This works fine, and with the XAML below, I have two list boxes, linked as I wanted them to be, and when I double click on an entry in one list box the other textbox populates with the selected item from the other list...which is perfect.
XAML:
C#:
<ListBox x:Name="codeList" Grid.ColumnSpan="2" Grid.RowSpan="3" Grid.Column="1" Grid.Row="7" FontSize="10" ItemsSource="{Binding codeColumn}" DisplayMemberPath="Code" SelectedValuePath="Code" IsSynchronizedWithCurrentItem="True" MouseDoubleClick="codeList_MouseDoubleClick"/>
The projList is exactly the same.
I was attempting to filter with:
C#:
DataView code = new DataView(table);
code.RowFilter = $"Code LIKE '*{codEntryTB.Text}'";
I have tried a lot of variations of this, based on the MSDN site (though I find that quite lacking on this particular issue - having a single example of "Code < 3", and various other tutorial sites - I can't see why it is not working.
I feel like I am missing something, like refreshing the codeList after the filter so that the filter takes effect, but every tutorial I have seen omits this as if it is not necessary and should happen automatically, so a little lost on why nothing is happening.