How to Read some of the properties of the ItemSource when Laying out the Children?
Posted
by user275561
on Stack Overflow
See other posts from Stack Overflow
or by user275561
Published on 2010-04-06T15:02:20Z
Indexed on
2010/04/06
15:03 UTC
Read the original article
Hit count: 360
Silverlight
|xaml
Assume that I have the ItemSource bound and i am getting the data. Now what I want is this. The ItemSource will contain Data that tells where each button should be. For Example: The first Button could be at Left:200,Top:0, the Second could be Left:50 Top:20.
</ItemsControl.Resources>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<Controls:MatrixCanvas />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<item:CustomButton
Height="{Binding btnSize}"
Width="{Binding btnSize}"
Style="{Binding bbColor,Converter={StaticResource ButtonStyleConverter}}"
/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
protected override Size ArrangeOverride(Size finalSize)
{
foreach (var child in Children)
{
//The child
}
return base.ArrangeOverride(finalSize);
}
The Child however is not giving me access to the Item that I want. Is their a good solution for this? Am I going about this the wrong way? The reason I am doing it like this is because their can be buttons added dynamically, removed, some buttons will need to move around etc..
© Stack Overflow or respective owner