J'ai un ListBox
:WPF Liaison de données Erreur dans ListBox
<ListBox x:Name="HistogramListBox" Grid.Column="1" Margin="8,2,8,0"
HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
Template="{StaticResource HistogramListBoxControlTemplate}"
ItemContainerStyle="{StaticResource HistogramListBoxItem}"
ItemTemplate="{DynamicResource BucketTemplate}" />
qui utilise un DataTemplate
qui utilise à son tour un ValueConverter
pour déterminer la hauteur du ListBoxItem
:
<DataTemplate x:Key="BucketTemplate">
<StackPanel>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="100"/>
</Grid.RowDefinitions>
<StackPanel HorizontalAlignment="Stretch" VerticalAlignment="Bottom">
<Rectangle Grid.Row="0" StrokeThickness="1" VerticalAlignment="Bottom"
Stroke="{Binding ElementName=MainElement, Path=BucketStroke}"
Fill="{Binding ElementName=MainElement, Path=BucketFill}" >
<Rectangle.Height>
<MultiBinding Converter="{StaticResource HistogramValueToPercentageConverter}">
<Binding Mode="OneWay" Path="ItemCount" />
<Binding RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type local:Histogram}}" />
</MultiBinding>
</Rectangle.Height>
</Rectangle>
</StackPanel>
</Grid>
</StackPanel>
</DataTemplate>
Le ListBox
ItemsSource
est un int[]
. Lorsque j'exécute le code, il est impossible de trouver 'ItemCount' sur un Int32. Je pensais qu'il a eu le nombre d'éléments de la ListBox
(je me trompe évidemment).
Quelqu'un peut-il me dire comment je peux obtenir mon ValueConverter
pour savoir sur quel article je suis.
Merci
Dan
Merci Ray, je savais que c'était quelque chose de stupide qui me manquait –