Reputation: 4885
I have used WPF very little so I'm looking for the simplest most straightforward way to accomplish this task.
Basically I have a Dictionary where the key is some identifier, and the value is a description. I wish to display a grid/listview of the descriptions with the intention of adding/removing rows by their non-displayed identifier.
How can this be accomplished quickly and easily?
Upvotes: 2
Views: 437
Reputation: 45106
Sample code binding to a dictionary list. To display the value replace Key with Value. Dictionary is not an observable collection so the UI will not dynamically pick up inserts and deletes.
<ListView ItemsSource="{Binding Path=GabeLib.DLFTSwordReverse, Mode=OneWay}" DisplayMemberPath="Key"
VirtualizingStackPanel.IsVirtualizing="True" VirtualizingStackPanel.VirtualizationMode="Recycling" ScrollViewer.IsDeferredScrollingEnabled="True"
ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Visible"/>
If you set Mode=TwoWay I think you could even update the Value.
Upvotes: 1