private void IsCheckedChanged(DependencyObject o, DependencyProperty p)
        {
            RadioMenuFlyoutItem radioItem = o as RadioMenuFlyoutItem;
            TextBlock           stateText;

            if (itemStates.TryGetValue(radioItem.Text, out stateText))
            {
                UpdateTextState(radioItem, stateText);
            }
        }
Exemplo n.º 2
0
        public ProjectsView()
        {
            InitializeComponent();
            Loaded += ProjectsView_Loaded;

            foreach (var category in Enum.GetValues(typeof(Project.ProjectCategory)).Cast <Project.ProjectCategory>())
            {
                var menuItem = new RadioMenuFlyoutItem()
                {
                    Text = Project.GetCategoryTitle(category)
                };
                menuItem.Click += CategoryItem_Click;
                CategoryFlyout.Items.Add(menuItem);
            }
            RefreshProjects();
        }
        private static RadioMenuFlyoutItem GetRadioItem(RadioMenuItemViewModel viewModel)
        {
            var item = new RadioMenuFlyoutItem();

            item.SetBinding(MenuFlyoutItem.TextProperty, new Binding
            {
                Source = viewModel,
                Path   = new PropertyPath(nameof(MenuItemViewModelBase.Text)),
                Mode   = BindingMode.OneWay
            });

            item.SetBinding(ToolTipService.ToolTipProperty, new Binding
            {
                Source = viewModel,
                Path   = new PropertyPath(nameof(MenuItemViewModelBase.Description)),
                Mode   = BindingMode.OneWay
            });

            item.SetBinding(MenuFlyoutItem.IconProperty, new Binding
            {
                Source    = viewModel,
                Path      = new PropertyPath(nameof(MenuItemViewModelBase.Icon)),
                Converter = IconConverter,
                Mode      = BindingMode.OneWay
            });

            item.SetBinding(RadioMenuFlyoutItem.GroupNameProperty, new Binding
            {
                Source = viewModel,
                Path   = new PropertyPath(nameof(RadioMenuItemViewModel.GroupName)),
                Mode   = BindingMode.OneWay
            });

            item.SetBinding(RadioMenuFlyoutItem.IsCheckedProperty, new Binding
            {
                Source = viewModel.BindingSource,
                Path   = new PropertyPath(viewModel.BindingPath),
                Mode   = BindingMode.TwoWay
            });

            return(item);
        }
        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");
                stateText.Name = radioItem.Text + "State";                 // Uno specific to allow _app.Query() in UI Tests.
                UpdateTextState(radioItem, stateText);
                ItemStates.Children.Add(stateText);

                itemStates.Add(radioItem.Text, stateText);
            }
        }
 private void UpdateTextState(RadioMenuFlyoutItem item, TextBlock textBlock)
 {
     textBlock.Text = item.IsChecked ? "Checked" : "Unchecked";
 }