AXML
<!-- IMAGE AND TEXT OBJECTS -->
<Image Canvas.Left="10" Canvas.Top="200" x:Name="imgObject0" Source="" />
<Image Canvas.Left="10" Canvas.Top="200" x:Name="imgObject1" Source="" />
<Image Canvas.Left="10" Canvas.Top="200" x:Name="imgObject2" Source="" />
<Image Canvas.Left="10" Canvas.Top="200" x:Name="imgObject3" Source="" />
<Image Canvas.Left="10" Canvas.Top="200" x:Name="imgObject4" Source="" />
<Image Canvas.Left="10" Canvas.Top="200" x:Name="imgObject5" Source="" />
<Image Canvas.Left="10" Canvas.Top="200" x:Name="imgObject6" Source="" />
<Image Canvas.Left="10" Canvas.Top="200" x:Name="imgObject7" Source="" />
<Image Canvas.Left="10" Canvas.Top="200" x:Name="imgObject8" Source="" />
<Image Canvas.Left="10" Canvas.Top="200" x:Name="imgObject9" Source="" />
<Image Canvas.Left="10" Canvas.Top="200" x:Name="imgObject10" Source="" />
<Image Canvas.Left="10" Canvas.Top="200" x:Name="imgObject11" Source="" />
<Image Canvas.Left="10" Canvas.Top="200" x:Name="imgObject12" Source="" />
<Image Canvas.Left="10" Canvas.Top="200" x:Name="imgObject13" Source="" />
<Image Canvas.Left="10" Canvas.Top="200" x:Name="imgObject14" Source="" />
<Image Canvas.Left="10" Canvas.Top="200" x:Name="imgObject15" Source="" />
<Image Canvas.Left="10" Canvas.Top="200" x:Name="imgObject16" Source="" />
<Image Canvas.Left="10" Canvas.Top="200" x:Name="imgObject17" Source="" />
<Image Canvas.Left="10" Canvas.Top="200" x:Name="imgObject18" Source="" />
<Image Canvas.Left="10" Canvas.Top="200" x:Name="imgObject19" Source="" />
<TextBlock Canvas.Left="10" Canvas.Top="200" x:Name="txtObject0" >AAA</TextBlock>
<TextBlock Canvas.Left="10" Canvas.Top="200" x:Name="txtObject1" >AAA</TextBlock>
<TextBlock Canvas.Left="10" Canvas.Top="200" x:Name="txtObject2" >AAA</TextBlock>
<TextBlock Canvas.Left="10" Canvas.Top="200" x:Name="txtObject3" >AAA</TextBlock>
<TextBlock Canvas.Left="10" Canvas.Top="200" x:Name="txtObject4" >AAA</TextBlock>
<TextBlock Canvas.Left="10" Canvas.Top="200" x:Name="txtObject5" >AAA</TextBlock>
<TextBlock Canvas.Left="10" Canvas.Top="200" x:Name="txtObject6" >AAA</TextBlock>
<TextBlock Canvas.Left="10" Canvas.Top="200" x:Name="txtObject7" >AAA</TextBlock>
<TextBlock Canvas.Left="10" Canvas.Top="200" x:Name="txtObject8" >AAA</TextBlock>
<TextBlock Canvas.Left="10" Canvas.Top="200" x:Name="txtObject9" >AAA</TextBlock>
<TextBlock Canvas.Left="10" Canvas.Top="200" x:Name="txtObject10" >AAA</TextBlock>
<TextBlock Canvas.Left="10" Canvas.Top="200" x:Name="txtObject11" >AAA</TextBlock>
<TextBlock Canvas.Left="10" Canvas.Top="200" x:Name="txtObject12" >AAA</TextBlock>
<TextBlock Canvas.Left="10" Canvas.Top="200" x:Name="txtObject13" >AAA</TextBlock>
<TextBlock Canvas.Left="10" Canvas.Top="200" x:Name="txtObject14" >AAA</TextBlock>
<TextBlock Canvas.Left="10" Canvas.Top="200" x:Name="txtObject15" >AAA</TextBlock>
<TextBlock Canvas.Left="10" Canvas.Top="200" x:Name="txtObject16" >AAA</TextBlock>
<TextBlock Canvas.Left="10" Canvas.Top="200" x:Name="txtObject17" >AAA</TextBlock>
<TextBlock Canvas.Left="10" Canvas.Top="200" x:Name="txtObject18" >AAA</TextBlock>
<TextBlock Canvas.Left="10" Canvas.Top="200" x:Name="txtObject19" >AAA</TextBlock>
Code
//*********************************************
//*********************************************
//********** GET PAGE OBJECT CONTROL **********
//*********************************************
//*********************************************
private object GetPageObjectControl(int ObjectsType, int ObjectIndex)
{
try
{
if (ObjectsType == UiPageObjects.OBJECT_TYPE_IMAGE)
{
switch (ObjectIndex)
{
case 0:
return (imgObject0);
case 1:
return (imgObject1);
case 2:
return (imgObject2);
case 3:
return (imgObject3);
case 4:
return (imgObject4);
case 5:
return (imgObject5);
case 6:
return (imgObject6);
case 7:
return (imgObject7);
case 8:
return (imgObject8);
case 9:
return (imgObject9);
case 10:
return (imgObject10);
case 11:
return (imgObject11);
case 12:
return (imgObject12);
case 13:
return (imgObject13);
case 14:
return (imgObject14);
case 15:
return (imgObject15);
case 16:
return (imgObject16);
case 17:
return (imgObject17);
case 18:
return (imgObject18);
case 19:
return (imgObject19);
default:
return (null);
}
}
else if (ObjectsType == UiPageObjects.OBJECT_TYPE_TEXT)
{
switch (ObjectIndex)
{
case 0:
return (txtObject0);
case 1:
return (txtObject1);
case 2:
return (txtObject2);
case 3:
return (txtObject3);
case 4:
return (txtObject4);
case 5:
return (txtObject5);
case 6:
return (txtObject6);
case 7:
return (txtObject7);
case 8:
return (txtObject8);
case 9:
return (txtObject9);
case 10:
return (txtObject10);
case 11:
return (txtObject11);
case 12:
return (txtObject12);
case 13:
return (txtObject13);
case 14:
return (txtObject14);
case 15:
return (txtObject15);
case 16:
return (txtObject16);
case 17:
return (txtObject17);
case 18:
return (txtObject18);
case 19:
return (txtObject19);
default:
return (null);
}
}
else
{
return (null);
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine("Exception: " + ex.Message);
return (null);
}
}
//----- CLEAR ALL THE OBJECTS -----
for (Index = 0; Index < MAX_PAGE_OBJECTS; Index++)
{
object PageObject = GetPageObjectControl(UiPageObjects.OBJECT_TYPE_IMAGE, Index);
if (PageObject != null)
{
Image imgPageObject = (Image)PageObject;
imgPageObject.Visibility = Visibility.Collapsed;
}
}
for (Index = 0; Index < MAX_PAGE_OBJECTS; Index++)
{
object PageObject = GetPageObjectControl(UiPageObjects.OBJECT_TYPE_TEXT, Index);
if (PageObject != null)
{
TextBlock txtPageObject = (TextBlock)PageObject;
txtPageObject.Visibility = Visibility.Collapsed;
}
}
Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.