Hello,
I'm using the TileView to layout my app and added some objects in the different TilePanes. I've added a Grid, but how can I access the object in code?
Example:
<
igTV:XamWebTileView x:Name="TileView" ColumnsInPage="2" RowsInPage="2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"><igTV:TilePane x:Name="PaneTopLeft" Header="PaneTopLeftHeader" SizeChanged="PaneTopLeft_SizeChanged"><Grid x:Name="GridName"></Grid></igTV:TilePane><igTV:TilePane x:Name="PaneTopRight" Header="PaneTopRightHeader"></igTV:TilePane><igTV:TilePane x:Name="PaneBottomLeft" Header="PaneBottomLeftHeader"></igTV:TilePane><igTV:TilePane x:Name="PaneBottomRight" Header="PaneBottomRightHeader"></igTV:TilePane></igTV:XamWebTileView>
In the PaneTopLeft_SizeChanged code I want to use the grid GridName,but it is null!
Arjan
Hi Arjan,Use this code to get the grid:private void PaneTopLeft_SizeChanged(object sender, SizeChangedEventArgs e){Grid grid = (sender as TilePane).Content as Grid;}Regards,Marin
Hello Marin,
Yes, I found that out, but why is it not possible to get the object by name. If I have a stackpanel inside the grid with multiple objects in it I need to use very long statements to get the object while using the name would shorten it all.
Thanks,
Hi Arjan,You can reinitialize the member variables generated by the VisualStudio.Go to your user control constructor, right click on InitalizeComponent method and select Go To Definition. Get the lines you need and put them to the layout updated event-handler.Sample XAML:<TileView:XamWebTileView x:Name="view1" LayoutUpdated="view1_LayoutUpdated"> <TileView:TilePane x:Name="tile1"> <Grid x:Name="grid1"> <Button x:Name="button1" Content="button"></Button> </Grid> </TileView:TilePane></TileView:XamWebTileView>private void view1_LayoutUpdated(object sender, EventArgs e){ if (this.button1 == null) { // This code was generated by a tool. The location is : mainpage.g.cs InitializeComponent() method this.view1 = ((Infragistics.Silverlight.Controls.XamWebTileView)(this.FindName("view1"))); this.tile1 = ((Infragistics.Silverlight.Controls.TilePane)(this.FindName("tile1"))); this.grid1 = ((System.Windows.Controls.Grid)(this.FindName("grid1"))); this.button1 = ((System.Windows.Controls.Button)(this.FindName("button1"))); }}Regards,Marin
Thanks Marin,
This 'workaround' makes life a little easier.But I still see it as a workaround, to me it looks like a bug in the control design.
This is a common Silverlight limitation, we cannot override the logical tree in Silverlight. The workaround uses the fact that FindName method uses the visual tree and we have to wait for layout update event to initialize members.Marin