Filtering ICollectionView binded to ItemsControl

前端 未结 1 991
予麋鹿
予麋鹿 2020-12-22 11:06

I want to make an WPF app for browsing recipes for dishes. Having trouble with filtering data.

I\'m using ItemsControl to make my data look like \"tiles\" in the win

相关标签:
1条回答
  • 2020-12-22 11:34

    this.DataContext = ItemsView; - with such DataContext binding Text="{Binding Szukane}" cannot possibly work, bacause Szukane is not a property of ItemsView. you need to change binding source:

    Text="{Binding Szukane, RelativeSource={RelativeSource AncestorType=Page} UpdateSourceTrigger=PropertyChanged}"

    Alternatively create a view model, with contains both ItemsView and Szukane properties, and use it for DataContext.

    I also recommend to add a delay for Text binding to reduce amount of filtering while typing:

    Text="{Binding Szukane, Delay=250, RelativeSource=...}

    0 讨论(0)
提交回复
热议问题