I have a viewmodel which contains an ObservableCollection of objects name MyLabel. These objects have 3 properties (content, rowNr, columnNr) which should be bound to the Content, Grid.Rowand Grid.Column attributes respectively.
The reason I defined ItemsControl is because it didnt work inside my grid, that is I couldnt bind rowNr and columnNr since the grids Grid.Column /Grid.Row properties kept overwriting my data.
How can I make this work so that my labels are inside of the grid?
<StackPanel>
<ItemsControl ItemsSource="{Binding Path=MyLabelList}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Label Content="{Binding content}" Grid.Column="{Binding columnNr}" Grid.Row="{Binding rowNr}" Style="{StaticResource MyLabel}" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
</Grid>
</StackPanel>