コード例 #1
0
        void SetupContextMenu()
        {
            if (Content == null || !ShowContextActions)
            {
                return;
            }

            if (!Cell.HasContextActions)
            {
                if (VisualTreeHelper.GetChildrenCount(this) > 0)
                {
                    ContextMenuService.SetContextMenu(VisualTreeHelper.GetChild(this, 0), null);
                }

                return;
            }

            ApplyTemplate();

            ContextMenu menu = new CustomContextMenu();

            menu.SetBinding(ItemsControl.ItemsSourceProperty, new System.Windows.Data.Binding("ContextActions"));

            ContextMenuService.SetContextMenu(VisualTreeHelper.GetChild(this, 0), menu);
        }
コード例 #2
0
        void SetupContextMenu()
        {
            if (Content == null || !ShowContextActions)
            {
                return;
            }

            if (!Cell.HasContextActions)
            {
                ContextMenuService.SetContextMenu(this, null);
                return;
            }

            ApplyTemplate();

            ContextMenu menu = new CustomContextMenu();

            menu.SetBinding(ItemsControl.ItemsSourceProperty, new System.Windows.Data.Binding("ContextActions"));

            ContextMenuService.SetContextMenu(this, menu);
        }