Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Create a view with a Collection property and a PostCode property. Bind the PostCode TwoWay, let the setter raise OnPropertyChanged for the Collection property, and let the collection property return a collection based on the current value of the PostCode property.</p> <pre><code>internal class MyView : INotifyPropertyChanged { private string _postCode; public string PostCode { get { return _postCode; } set { _postCode = value; OnPropertyChanged("PostCode"); OnPropertyChanged("FilteredItems"); } } public ObservableCollection&lt;Address&gt; Items { get; set; } public IEnumerable&lt;Address&gt; FilteredItems { get { return Items.Where(o =&gt; o.PostCode == _postCode).ToArray(); } } public event PropertyChangedEventHandler PropertyChanged; private void OnPropertyChanged( string propertyName ) { if( PropertyChanged != null ) { PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); } } } &lt;Grid DataContext="{Binding Path=myViewInstance}"&gt; &lt;TextBox Text="{Binding Path=PostCode, Mode=TwoWay}"/&gt; &lt;ListBox Grid.Row="0" Grid.Column="1" Grid.RowSpan="2" ItemsSource="{Binding Path=FilteredItems}"&gt; &lt;ListBox.ItemsPanel&gt; &lt;ItemsPanelTemplate&gt; &lt;VirtualizingStackPanel Orientation="Horizontal" IsItemsHost="true" /&gt; &lt;/ItemsPanelTemplate&gt; &lt;/ListBox.ItemsPanel&gt; &lt;ListBox.ItemTemplate&gt; &lt;DataTemplate&gt; &lt;StackPanel Grid.Row="0" Grid.Column="1" Grid.RowSpan="2" Orientation="Vertical"&gt; &lt;Label Content="{Binding Address1}"&gt;&lt;/Label&gt; &lt;Label Content="{Binding Address2}"&gt;&lt;/Label&gt; &lt;Label Content="{Binding Town}"&gt;&lt;/Label&gt; &lt;Label Content="{Binding PostCode}"&gt;&lt;/Label&gt; &lt;Label Content="{Binding Country}"&gt;&lt;/Label&gt; &lt;CheckBox Content="{Binding Include}"&gt;&lt;/CheckBox&gt; &lt;/StackPanel&gt; &lt;/DataTemplate&gt; &lt;/ListBox.ItemTemplate&gt; &lt;/ListBox&gt; &lt;/Grid&gt; </code></pre> <p><strong><em>Note:</strong> My "Address" class might differ from yours.</em></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload