bool ISelectionContainer.this[object item]
 {
     get
     {
         var typed = ArgValidation.ThrowIfMismatch <T>(item, "item");
         return(IsSelected(typed));
     }
 }
Example #2
0
        private static void TrySetupMenu(DependencyObject obj)
        {
            var property = GetIsOpenProperty(obj);
            var menu     = GetMenu(obj);

            if (menu != null && property != null)
            {
                var toggle = ArgValidation.ThrowIfMismatch <FrameworkElement>(obj, "obj");
                menu.PlacementTarget = toggle;
                menu.Placement       = PlacementMode.Bottom;
                menu.SetBinding(ContextMenu.IsOpenProperty, new Binding(property.Name)
                {
                    Source = toggle, Mode = BindingMode.OneWay
                });
                ContextMenuService.SetContextMenu(toggle, menu);
            }
        }