How to access a Control inside the data template in C# Metro UI in the code behind

后端 未结 3 561
心在旅途
心在旅途 2020-11-30 13:56

I have a MediaElement that resides inside the datatemplate of flipview, i want to access that MediaElement named \"video\" in the code behind so that i can assign properties

3条回答
  •  长情又很酷
    2020-11-30 14:34

    I wrote a blog article on this very topic about a year ago. Perhaps it will help you: http://blog.jerrynixon.com/2012/09/how-to-access-named-control-inside-xaml.html

    The gist is this. You must parse through the visual tree to get all elements, and then you can use something like LINQ to filter the results and get your objects.

提交回复
热议问题