I have a code like this
foreach(UIElement iue in layout.Children)
{
if (iue is Panorama)
{
//some code
}
}
but this is always false.
I also tried
foreach(UIElement iue in layout.Children)
{
if (iue.getType() == typeof(Panorama))
{
//some code
}
}
with no success.
I wrote a test app and your code should work. If you have double checked everything else keep in mind that the Children
property will return top level elements only. If your Panorama
control is a child element then you will need to get to it using the Children
property of the parent control. Another thing to check is that the namespace of the control you used in the line typeof(Panorama)
is Microsoft.Phone.Controls
. You can do this by hitting F12 when you cursor is on the word Panorama
.
Just a little change in your code. try this, may will help you.
foreach(UIElement iue in layout.Children)
{
if (this.IsPanorama(iue ))
{
//some code
//Panorama control
}
else
{
//not aPanorama control
}
}
//just check whether a UI element is panorama or not
private bool IsPanorama(UIElement element)
{
bool isPanorama =false;
try{
Panorama p = (Panorama)element;
isPanorama = true;
return isPanorama ;
}
catch(Exception ex)
{
isPanorama = false;
return isPanorama ;
}
}
Just checked the XAML again and found that there was no Panorama but a UserControl that was inherited from Panorama with name PanoramaFullScreen (to have full screen PanoramaItem).
Thank you everyone for the response though.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.