Bind to ICollectionView.Count property in XAML
Asked Answered
K

1

10

I'm trying to bind a text box to the count of a filtered, collection view in XAML. It doesn't generate any errors but it also doesn't produce any output. Does anyone know how to do this?

Here's are some snippets of my XAML:

<Window.Resources>
  <CollectionViewSource x:Key="MyView" Source="{Binding MyBinding}" Filter="MyFilter" />
</Window.Resources>

...

<TextBlock>
  <TextBlock.Text>
    <Binding Source="{StaticResource MyView}" Path="View.Count"  
      StringFormat="{}Count: {0:D}" />
  </TextBlock.Text>
</TextBlock>

Basically, I'm trying to display the count of filtered items in the List.

Kiethkiev answered 21/7, 2009 at 9:54 Comment(0)
B
13

You don't need the "View." in the path. it should just be:

Path="Count"
Black answered 21/7, 2009 at 9:58 Comment(1)
Correct. This link will help you debug bindings: beacosta.com/blog/?p=52Limburger

© 2022 - 2024 — McMap. All rights reserved.