c# - Changed Screen Orientation MediaElement Disappear From Screen -


i have interesting problem project. m working on orientation of app , problem videoelement disappered when changed screen orientation portrait or landscape. m using same code image , working correctly. so, didn't understand issue is. there idea ? here code is;

this line return null mediaelement:

mediaelement mediacontrol = recursechildren<mediaelement>(fwquestions).where(p => p.name == "myvideoelement" + elementorder).firstordefault(); 

but line same structure return image correctly:

image imagecontroller = recursechildren<image>(fwquestions).where(p => p.name == "questionimage" + elementorder).firstordefault(); 

my codes :

mediaelement myvideoelement = new mediaelement(); myvideoelement.name = "myvideoelement" + currentquestion; myvideoelement.width = (window.current.bounds.width * 0.2) - 10; myvideoelement.height = 300; myvideoelement.margin = new thickness(10); myvideoelement.source = new uri(appconfiguration.testvideolink + questionvideolink, urikind.absolute); myvideoelement.autoplay = false; myvideoelement.margin = new thickness(0, 10, 0, 10); myvideoelement.aretransportcontrolsenabled = true; myvideoelement.horizontalalignment = horizontalalignment.center; myvideoelement.visibility = visibility.collapsed; spmediabody.children.add(myvideoelement);  dynamicgrid.children.add(spmediabody); pnlgeneralbody.children.add(dynamicgrid); fwquestions.items.add(pnlgeneralbody);  public static ienumerable<t> recursechildren<t>(dependencyobject root) t : uielement         {             if (root t)             {                 yield return root t;             }              if (root != null)             {                 var count = visualtreehelper.getchildrencount(root);                   (var idx = 0; idx < count; idx++)                 {                     foreach (var child in recursechildren<t>(visualtreehelper.getchild(root, idx)))                     {                         yield return child;                     }                 }             }         }  private void page_sizechanged(object sender, sizechangedeventargs e)         {             if (ispageloadcomplete)             {                 (int = 0; < appconfiguration.questionlist.allques.count; i++)                 {                     string elementorder = i.tostring();                       grid grdbody = recursechildren<grid>(fwquestions).where(p => p.name == "dynamicgrid" + elementorder).firstordefault();                     mediaelement mediacontrol = recursechildren<mediaelement>(fwquestions).where(p => p.name == "myvideoelement" + elementorder).firstordefault();                     if (mediacontrol != null && mediacontrol.visibility == visibility.visible)                     {                         mediacontrol.width = (window.current.bounds.width * 0.2) - 10;                         grdbody.columndefinitions[0].width = new gridlength((window.current.bounds.width * 0.2) - 5, gridunittype.pixel);                         grdbody.columndefinitions[1].width = new gridlength((window.current.bounds.width * 0.8) - 5, gridunittype.pixel);                     }                     else                     {                         grdbody.columndefinitions[0].width = new gridlength((window.current.bounds.width * 0), gridunittype.pixel);                         grdbody.columndefinitions[1].width = new gridlength((window.current.bounds.width * 1) - 10, gridunittype.pixel);                     }                      mediaelement audiocontrol = recursechildren<mediaelement>(fwquestions).where(p => p.name == "myaudioelement" + elementorder).firstordefault();                     if (audiocontrol != null && audiocontrol.visibility == visibility.visible)                     {                         audiocontrol.width = (window.current.bounds.width * 0.2) - 10;                         grdbody.columndefinitions[0].width = new gridlength((window.current.bounds.width * 0.2) - 5, gridunittype.pixel);                         grdbody.columndefinitions[1].width = new gridlength((window.current.bounds.width * 0.8) - 5, gridunittype.pixel);                     }                     else                     {                         grdbody.columndefinitions[0].width = new gridlength((window.current.bounds.width * 0), gridunittype.pixel);                         grdbody.columndefinitions[1].width = new gridlength((window.current.bounds.width * 1) - 10, gridunittype.pixel);                     }                      image imagecontroller = recursechildren<image>(fwquestions).where(p => p.name == "questionimage" + elementorder).firstordefault();                     if (imagecontroller != null && imagecontroller.visibility == visibility.visible)                     {                         imagecontroller.width = (window.current.bounds.width * 0.2) - 10;                         grdbody.columndefinitions[0].width = new gridlength((window.current.bounds.width * 0.2) - 5, gridunittype.pixel);                         grdbody.columndefinitions[1].width = new gridlength((window.current.bounds.width * 0.8) - 5, gridunittype.pixel);                     }                     else                     {                         grdbody.columndefinitions[0].width = new gridlength((window.current.bounds.width * 0), gridunittype.pixel);                         grdbody.columndefinitions[1].width = new gridlength((window.current.bounds.width * 1) - 10, gridunittype.pixel);                     }                 }              }         } 


Comments

Popular posts from this blog

c++ - How to add Crypto++ library to Qt project -

jQuery Mobile app not scrolling in Firefox -

How to use vim as editor in Matlab GUI -