1. 程式人生 > >UWP開發學習筆記3

UWP開發學習筆記3

count span help button private bject route foreach wp開發

獲取可視化狀態列表

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