public RadioMenuFlyoutItemPage() { this.InitializeComponent(); itemStates = new Dictionary <string, TextBlock>(); if (ApiInformation.IsPropertyPresent("Windows.UI.Xaml.Controls.MenuFlyoutItem", "Icon")) { IconMenuFlyoutItem.Icon = new SymbolIcon(Symbol.Calendar); IconRadioMenuFlyoutItem.Icon = new SymbolIcon(Symbol.Calculator); } if (ApiInformation.IsPropertyPresent("Windows.UI.Xaml.Controls.Grid", "ColumnSpacing")) { InfoGrid.ColumnSpacing = 12; ItemNames.Spacing = 4; ItemStates.Spacing = 4; } // register all RadioMenuFlyoutItems foreach (MenuFlyoutItemBase item in ButtonMenuFlyout.Items) { if (item is RadioMenuFlyoutItem) { RadioMenuFlyoutItem radioItem = item as RadioMenuFlyoutItem; radioItem.RegisterPropertyChangedCallback(RadioMenuFlyoutItem.IsCheckedProperty, new DependencyPropertyChangedCallback(IsCheckedChanged)); TextBlock nameText = new TextBlock(); nameText.Text = radioItem.Text; ItemNames.Children.Add(nameText); TextBlock stateText = new TextBlock(); AutomationProperties.SetName(stateText, radioItem.Text + "State"); UpdateTextState(radioItem, stateText); ItemStates.Children.Add(stateText); itemStates.Add(radioItem.Text, stateText); } } }
private void RegisterItem(MenuFlyoutItemBase item) { if (item is RadioMenuFlyoutItem) { RadioMenuFlyoutItem radioItem = item as RadioMenuFlyoutItem; radioItem.RegisterPropertyChangedCallback(RadioMenuFlyoutItem.IsCheckedProperty, new DependencyPropertyChangedCallback(IsCheckedChanged)); TextBlock nameText = new TextBlock(); nameText.Text = radioItem.Text; ItemNames.Children.Add(nameText); TextBlock stateText = new TextBlock(); AutomationProperties.SetName(stateText, radioItem.Text + "State"); UpdateTextState(radioItem, stateText); ItemStates.Children.Add(stateText); itemStates.Add(radioItem.Text, stateText); } }