Click here to Skip to main content
15,886,063 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a dictionary of key Guid and a network class value, and I wish to bind the ItemsControl Items to the Network classes inside the Dictionary

Here is the xaml I have.

HTML
<ItemsControl ItemsSource="{Binding NetworkList}" x:Name="iclItems" Grid.Column="1" Grid.Row="1">
            <ItemsControl.ItemTemplate>
                <DataTemplate>
                    <Grid removed="Orange" Width="250" Height="250" Margin="20">
                        
                    </Grid>
                </DataTemplate>
            </ItemsControl.ItemTemplate>
            <ItemsControl.ItemsPanel>
                <ItemsPanelTemplate>
                    <WrapGrid Orientation="Horizontal" />
                </ItemsPanelTemplate>
            </ItemsControl.ItemsPanel>
        </ItemsControl>


And here is the code behind that adds just a Network to the dictionary

C#
private Dictionary<Guid, Network> mdictNetworkList;
public Dictionary<Guid, Network> NetworkList
{
    get { return mdictNetworkList; }
    set { mdictNetworkList = value; }
}
public MainPage()
{
    this.InitializeComponent();

    mdictNetworkList = new Dictionary<Guid, Network>();
    Network objNetwork = new Network();
    mdictNetworkList.Add(objNetwork.ID, objNetwork);
}


I'm not getting any items being added. Any ideas why? I'm sorry if this has been asked before, but I couldn't find an answer to my problem that worked.
Posted
Updated 3-Feb-13 0:06am
v2

1 solution

When the value of NetworkList is changing then you are not firing RaisePropertyChanged event
e.g.
this.RaisePropertyChanged("NetworkList");


and where you are binding the DataContext in your code?

this.DataContext = this;
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900