Note that there are some explanatory texts on larger screens.

plurals
  1. POBinding key values of a dictionnary in a ListView C# XAML
    text
    copied!<p>I have a problem in binding elements of my dictionnary.My dictionnary contains an object as a key and an integer as a value.I have to bind this dictionnary in a ListView.The problem is that I need to reach properties of my object to bind them in the listview.Properties type is string.I didn't find solution, it's all about wpf but I'm using Windows8 with MVVM Light.</p> <p>There is my code:</p> <p>My List :</p> <pre><code>&lt;ListView ItemsSource="{Binding Path=MotDansTweet}" HorizontalAlignment="Left" Height="570" Margin="64,28,0,0" VerticalAlignment="Top" Width="350" Background="#FF009BB4" Grid.Column="1"&gt; &lt;StackPanel Height="118" Width="340"&gt; &lt;Grid Height="100"&gt; &lt;Grid HorizontalAlignment="Left" Height="122" VerticalAlignment="Top" Width="330" Margin="0,0,0,-22"&gt; &lt;Grid.ColumnDefinitions&gt; &lt;ColumnDefinition Width="137*" /&gt; &lt;ColumnDefinition Width="193*" /&gt; &lt;/Grid.ColumnDefinitions&gt; &lt;Image Source="{Binding Path=Key.ProfileImageUrl }" HorizontalAlignment="Left" Height="112" VerticalAlignment="Top" Width="127" /&gt; &lt;TextBlock Text="{Binding Path=Key.Username}" Grid.Column="1" HorizontalAlignment="Left" Margin="10,10,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Height="46" Width="173" /&gt; &lt;TextBlock Text="{Binding Path=Values}" Grid.Column="1" HorizontalAlignment="Left" Margin="10,61,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Height="41" Width="154" /&gt; &lt;/Grid&gt; &lt;/Grid&gt; &lt;/StackPanel&gt; &lt;/ListView&gt; </code></pre> <p>My Dictionnary :</p> <pre><code> private Dictionary&lt;ObjetFollowingFollowerFinal,int&gt; _motDansTweet ; public Dictionary&lt;ObjetFollowingFollowerFinal, int&gt; MotDansTweet { get { return _motDansTweet; } set { _motDansTweet = value; RaisePropertyChanged("MotDansTweet"); } } </code></pre> <p>My Object :</p> <pre><code> public class ObjetFollowingFollowerFinal { public string Username { get; set; } // I need it public string Description { get; set; } public string ProfileImageUrl { get; set; } //I need it public int StatusesCount { get; set; } public int FollowerCount { get; set; } public int FriendsCount { get; set; } public int ListedCount { get; set; } public List&lt;User&gt; ListeFollower = new List&lt;User&gt;(); public ObjetFollowingFollowerFinal() { } } </code></pre> <p>Thanks.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload