13 changed files with 309 additions and 55 deletions
@ -0,0 +1,35 @@ |
|||||
|
using System; |
||||
|
using System.Windows; |
||||
|
|
||||
|
namespace Microsoft.Windows.Controls.Core.Utilities |
||||
|
{ |
||||
|
public class ContextMenuUtilities |
||||
|
{ |
||||
|
public static readonly DependencyProperty OpenOnMouseLeftButtonClickProperty = DependencyProperty.RegisterAttached("OpenOnMouseLeftButtonClick", typeof(bool), typeof(FrameworkElement), new FrameworkPropertyMetadata(false, OpenOnMouseLeftButtonClickChanged)); |
||||
|
public static void SetOpenOnMouseLeftButtonClick(FrameworkElement element, bool value) |
||||
|
{ |
||||
|
element.SetValue(OpenOnMouseLeftButtonClickProperty, value); |
||||
|
} |
||||
|
public static bool GetOpenOnMouseLeftButtonClick(FrameworkElement element) |
||||
|
{ |
||||
|
return (bool)element.GetValue(OpenOnMouseLeftButtonClickProperty); |
||||
|
} |
||||
|
|
||||
|
public static void OpenOnMouseLeftButtonClickChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
||||
|
{ |
||||
|
var control = (FrameworkElement)sender; |
||||
|
if ((bool)e.NewValue) |
||||
|
{ |
||||
|
control.PreviewMouseLeftButtonDown += (s, args) => |
||||
|
{ |
||||
|
if (control.ContextMenu != null) |
||||
|
{ |
||||
|
control.ContextMenu.PlacementTarget = control; |
||||
|
control.ContextMenu.IsOpen = true; |
||||
|
} |
||||
|
}; |
||||
|
} |
||||
|
//TODO: remove handler when set to false
|
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
After Width: | Height: | Size: 156 B |
|
After Width: | Height: | Size: 201 B |
|
After Width: | Height: | Size: 205 B |
|
After Width: | Height: | Size: 142 B |
|
After Width: | Height: | Size: 340 B |
|
After Width: | Height: | Size: 303 B |
@ -0,0 +1,17 @@ |
|||||
|
using System; |
||||
|
using System.Windows.Input; |
||||
|
|
||||
|
namespace Microsoft.Windows.Controls.PropertyGrid.Commands |
||||
|
{ |
||||
|
public static class PropertyItemCommands |
||||
|
{ |
||||
|
private static RoutedCommand _resetValueCommand = new RoutedCommand(); |
||||
|
public static RoutedCommand ResetValue |
||||
|
{ |
||||
|
get |
||||
|
{ |
||||
|
return _resetValueCommand; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,48 @@ |
|||||
|
using System; |
||||
|
using System.Windows; |
||||
|
using System.Windows.Data; |
||||
|
using System.Windows.Media.Imaging; |
||||
|
|
||||
|
namespace Microsoft.Windows.Controls.PropertyGrid.Converters |
||||
|
{ |
||||
|
public class ValueSourceToImagePathConverter : IValueConverter |
||||
|
{ |
||||
|
#region IValueConverter Members
|
||||
|
|
||||
|
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) |
||||
|
{ |
||||
|
BaseValueSource bvs = (BaseValueSource)value; |
||||
|
|
||||
|
string uriPrefix = "/WPFToolkit.Extended;component/PropertyGrid/Images/"; |
||||
|
string imageName = "AdvancedProperties11"; |
||||
|
|
||||
|
switch (bvs) |
||||
|
{ |
||||
|
case BaseValueSource.Inherited: |
||||
|
case BaseValueSource.DefaultStyle: |
||||
|
case BaseValueSource.ImplicitStyleReference: |
||||
|
imageName = "Inheritance11"; |
||||
|
break; |
||||
|
case BaseValueSource.DefaultStyleTrigger: |
||||
|
break; |
||||
|
case BaseValueSource.Style: |
||||
|
imageName = "Style11"; |
||||
|
break; |
||||
|
|
||||
|
case BaseValueSource.Local: |
||||
|
imageName = "Local11"; |
||||
|
break; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
return new BitmapImage(new Uri(String.Format("{0}{1}.png", uriPrefix, imageName), UriKind.RelativeOrAbsolute)); |
||||
|
} |
||||
|
|
||||
|
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) |
||||
|
{ |
||||
|
throw new NotImplementedException(); |
||||
|
} |
||||
|
|
||||
|
#endregion
|
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,42 @@ |
|||||
|
using System; |
||||
|
using System.Windows; |
||||
|
using System.Windows.Data; |
||||
|
|
||||
|
namespace Microsoft.Windows.Controls.PropertyGrid.Converters |
||||
|
{ |
||||
|
class ValueSourceToToolTipConverter : IValueConverter |
||||
|
{ |
||||
|
#region IValueConverter Members
|
||||
|
|
||||
|
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) |
||||
|
{ |
||||
|
BaseValueSource bvs = (BaseValueSource)value; |
||||
|
string toolTip = "Advanced Properties"; |
||||
|
|
||||
|
switch (bvs) |
||||
|
{ |
||||
|
case BaseValueSource.Inherited: |
||||
|
case BaseValueSource.DefaultStyle: |
||||
|
case BaseValueSource.ImplicitStyleReference: |
||||
|
toolTip = "Inheritance"; |
||||
|
break; |
||||
|
case BaseValueSource.Style: |
||||
|
toolTip = "Style Setter"; |
||||
|
break; |
||||
|
|
||||
|
case BaseValueSource.Local: |
||||
|
toolTip = "Local"; |
||||
|
break; |
||||
|
} |
||||
|
|
||||
|
return toolTip; |
||||
|
} |
||||
|
|
||||
|
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) |
||||
|
{ |
||||
|
throw new NotImplementedException(); |
||||
|
} |
||||
|
|
||||
|
#endregion
|
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue