首页 > 其他 > 详细

UWP开发学习笔记3

时间:2019-01-06 13:25:40      阅读:121      评论:0      收藏:0      [点我收藏+]

获取可视化状态列表

private void Button_Click(object sender, RoutedEventArgs e)
{
    //获取CheckBox控件可视化树中的子元素数量
    int count = VisualTreeHelper.GetChildrenCount(ckbox);
    if (count > 0)
    {
        //获取CheckBox控件模板中的根元素
        FrameworkElement rootElement = VisualTreeHelper.GetChild(ckbox, 0) as FrameworkElement;
        if (rootElement != null)
        {
            //获取状态组列表
            var groups = VisualStateManager.GetVisualStateGroups(rootElement);
            foreach (VisualStateGroup group in groups)
            {
                Debug.WriteLine("状态组:" + group.Name);
                foreach (VisualState vs in group.States)
                {
                    Debug.WriteLine("\t状态:" + vs.Name);
                }
            }
        }
    }
}

 

UWP开发学习笔记3

原文:https://www.cnblogs.com/wzwyc/p/10228345.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!