开发者

((FrameworkElement)sender).Tag convert to class wp7

开发者 https://www.devze.com 2023-03-27 01:22 出处:网络
How I can convert like: var me = ((FrameworkElement)sender).Tag as ListBoxItem as Data; _ public class Data {

How I can convert like:

var me = ((FrameworkElement)sender).Tag as ListBoxItem as Data;

_

public class Data {
            public string url { get; set; }
            public string title { get; set; }
        }

 <Button Click="PlayMedia" Tag="{Binding}" 开发者_开发百科 Content="Play" />


Assuming that this code is in the PlayMedia event handler, you can do:

var button = sender as Button;
var data = button.Tag as Data;

If the button is contained in a ListBoxItem, then you'd have to use VisualTreeHelper to find it up the visual tree, starting with the button.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号