示例#1
0
        /*
         * DependencyPropertyChanged callbacks
         *
         */

        private static void OnIsContextMenuOpenChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            SplitButton s = (SplitButton)d;

            s.EnsureContextMenuIsValid();

            if (!s.ContextMenu.HasItems)
            {
                return;
            }

            bool value = (bool)e.NewValue;

            if (value && !s.ContextMenu.IsOpen)
            {
                s.ContextMenu.IsOpen = true;
            }
            else if (!value && s.ContextMenu.IsOpen)
            {
                s.ContextMenu.IsOpen = false;
            }
        }