我想使用WPF在TextBlock中綁定ItemControl的ItemsControl的ItemsSource的CountSource。使用WPF在TextBlock中綁定項目ItemsControl的ItemsSource
看看到我試過代碼
<Menu>
<MenuItem>
<MenuItem.Header>
<TextBlock Text="{Binding Path=(ItemsControl.ItemsSource.Item, RelativeSource={RelativeSource TemplatedParent}}" />
</MenuItem.Header>
<ItemsControl ItemsSource="{Binding PersonCollection}">
<ItemsControl.ItemTemplate>
<DataTemplate >
<StackPanel Orientation="Horizontal" Margin="2" MinWidth="100">
<TextBlock Text="{Binding Value.Text}"/>
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</MenuItem>
</Menu>
注:我需要得到由
Collection.Count
物業基於ItemsControl ItemsSource
不計。請幫助我。
什麼阻止你從'ItemsCource'而不是'ItemsSource'獲取'PersonCollection'的Count? – Gopichandar
@Gopichandar我在自定義控件中使用這個。所以,我需要根據ItemsSource Count來做出決定。請按照我的要求幫助我。 –
試一試'Path = Items.Count' – Gopichandar