public void ClearValue(DependencyPropertyKey key) { if (key == null) throw new ArgumentNullException("key"); ClearValue(key.DependencyProperty); }
private static void TestLogicalTree(Type controlType, DependencyProperty property, DependencyPropertyKey propertyKey = null) { var control = (DependencyObject)Activator.CreateInstance(controlType, true); Assert.That(control, Is.Not.Null); { var value = new object(); SetValue(value); { var children = LogicalTreeHelper.GetChildren(control); if (excludedPropertiesForLogicalChildSupportTest.Contains(property)) { Assert.That(children, Does.Not.Contain(value), "Logical children must NOT contain the value."); } else { Assert.That(children, Does.Contain(value), "Logical children must contain the value."); } } SetValue(null); { var children = LogicalTreeHelper.GetChildren(control); Assert.That(children, Does.Not.Contain(value), "Logical children must NOT contain the value."); } } { var value = new DependencyObject(); SetValue(value); { var children = LogicalTreeHelper.GetChildren(control); if (excludedPropertiesForLogicalChildSupportTest.Contains(property)) { Assert.That(children, Does.Not.Contain(value), "Logical children must NOT contain the value."); } else { Assert.That(children, Does.Contain(value), "Logical children must contain the value."); } } { var parent = LogicalTreeHelper.GetParent(value); Assert.That(parent, Is.Null, "Dependency-Objects don't support logical parents."); } SetValue(null); { var children = LogicalTreeHelper.GetChildren(control); Assert.That(children, Does.Not.Contain(value), "Logical children must NOT contain the value."); } } { var value = new FrameworkElement(); SetValue(value); { var children = LogicalTreeHelper.GetChildren(control); if (excludedPropertiesForLogicalChildSupportTest.Contains(property)) { Assert.That(children, Does.Not.Contain(value), "Logical children must NOT contain the value."); } else { Assert.That(children, Does.Contain(value), "Logical children must contain the value."); } } { var parent = LogicalTreeHelper.GetParent(value); if (excludedPropertiesForLogicalChildSupportTest.Contains(property)) { Assert.That(parent, Is.Not.EqualTo(control), "Parent should match."); } else { Assert.That(parent, Is.EqualTo(control), "Parent should match."); } } SetValue(null); { var children = LogicalTreeHelper.GetChildren(control); Assert.That(children, Does.Not.Contain(value), "Logical children must NOT contain the value."); } } void SetValue(object value) { if (propertyKey is null) { control.SetValue(property, value); } else { control.SetValue(propertyKey, value); } } }
// #region Static constructor /// <summary> /// /// </summary> static CLTreeViewItem() { /* Readonly registration */ MouseHoverStatePropertyKey = DependencyProperty.RegisterReadOnly("MouseHoverState", typeof(MouseHoverStates), typeof(CLTreeViewItem), new PropertyMetadata(MouseHoverStates.MouseOut)); MouseHoverStateProperty = MouseHoverStatePropertyKey.DependencyProperty; }
internal static void SetReadOnlyValue(this DependencyObject element, DependencyPropertyKey key, object value) { element.SetValue(key, value); }
static Window() { FrameworkElement.DefaultStyleKeyProperty.OverrideMetadata(typeof(Window), new FrameworkPropertyMetadata(typeof(Window))); Window.GlassMarginProperty = DependencyProperty.Register( "GlassMargin", typeof(GlassMargin), typeof(Window), new FrameworkPropertyMetadata(new GlassMargin(0, 0, 0, 0), FrameworkPropertyMetadataOptions.AffectsRender, Window.GlassMarginPropertyChanged) ); Window.BlurClientAreaProperty = DependencyProperty.Register( "BlurClientArea", typeof(bool), typeof(Window), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender, Window.BlurClientAreaPropertyChanged) ); Window.EnableNonClientAreaDrawingProperty = DependencyProperty.Register( "EnableNonClientAreaDrawing", typeof(bool), typeof(Window), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsMeasure, Window.EnableNonClientAreaDrawingPropertyChanged) ); Window.nonClientControlsKey = DependencyProperty.RegisterReadOnly( "NonClientControls", typeof(ObservableCollection <object>), typeof(Window), new FrameworkPropertyMetadata(new ObservableCollection <object>()) ); Window.NonClientControlsProperty = Window.nonClientControlsKey.DependencyProperty; Window.CustomWindowTitleProperty = DependencyProperty.Register( "CustomWindowTitle", typeof(object), typeof(Window) ); Window.SetParametersForBorderlessNonResizeableGlassWindowProperty = DependencyProperty.Register( "SetParametersForBorderlessNonResizeableGlassWindow", typeof(bool), typeof(Window), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender, Window.SetParametersForBorderlessNonResizeableGlassWindowPropertyChanged) ); Window.isDwmEnabledPropertyKey = DependencyProperty.RegisterReadOnly( "IsDwmEnabled", typeof(bool), typeof(Window), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender) ); Window.IsDwmEnabledProperty = Window.isDwmEnabledPropertyKey.DependencyProperty; Window.FadeInRequestedEvent = EventManager.RegisterRoutedEvent( "FadeInRequested", RoutingStrategy.Bubble, typeof(EventHandler), typeof(Window) ); Window.FadeOutRequestedEvent = EventManager.RegisterRoutedEvent( "FadeOutRequested", RoutingStrategy.Bubble, typeof(EventHandler), typeof(Window) ); }
public static T GetValueOrCreateOrDefault <T>(this DependencyObject dependencyObject, DependencyPropertyKey dependencyPropertyKey, bool create, Func <T> factoryMethod) { var value = (T)dependencyObject.GetValue(dependencyPropertyKey.DependencyProperty); if (value == null && create) { dependencyObject.SetReadOnlyValue(dependencyPropertyKey, value = factoryMethod()); } return(value); }
public void SetValue(DependencyPropertyKey key, object value) { if (key == null) throw new ArgumentNullException("key"); SetValue(key.DependencyProperty, value); }
DependencyPropertyRegistrator <T> RegisterReadOnly <TProperty>(Expression <Func <T, TProperty> > property, out DependencyPropertyKey propertyFieldKey, out DependencyProperty propertyField, PropertyMetadata metadata) { propertyFieldKey = DependencyProperty.RegisterReadOnly(GetPropertyName(property), typeof(TProperty), typeof(T), metadata); propertyField = propertyFieldKey.DependencyProperty; return(this); }
static KinectSensorManager() { UniqueKinectIdPropertyKey = DependencyProperty.RegisterReadOnly( "UniqueKinectId", typeof(string), typeof(KinectSensorManager), new PropertyMetadata(null)); KinectSensorAppConflictPropertyKey = DependencyProperty.RegisterReadOnly( "KinectSensorAppConflict", typeof(bool), typeof(KinectSensorManager), new PropertyMetadata(false, (sender, args) => ((KinectSensorManager)sender).NotifyAppConflict())); KinectSensorProperty = DependencyProperty.Register( "KinectSensor", typeof(KinectSensor), typeof(KinectSensorManager), new PropertyMetadata(null, KinectSensorOrStatusChanged)); KinectSensorStatusProperty = DependencyProperty.Register( "KinectSensorStatus", typeof(KinectStatus), typeof(KinectSensorManager), new PropertyMetadata(KinectStatus.Undefined, KinectSensorOrStatusChanged)); UniqueKinectIdProperty = UniqueKinectIdPropertyKey.DependencyProperty; KinectSensorEnabledProperty = DependencyProperty.Register( "KinectSensorEnabled", typeof(bool), typeof(KinectSensorManager), new PropertyMetadata(true, (sender, args) => ((KinectSensorManager)sender).EnsureKinectSensorRunningState())); SupportsCameraSettingsProperty = DependencyProperty.Register( "SupportsCameraSettings", typeof(bool), typeof(KinectSensorManager), new PropertyMetadata(false)); CameraSettingsProperty = DependencyProperty.Register( "CameraSettings", typeof(ColorCameraSettings), typeof(KinectSensorManager), new PropertyMetadata(null)); KinectSensorAppConflictProperty = KinectSensorAppConflictPropertyKey.DependencyProperty; ColorStreamEnabledProperty = DependencyProperty.Register( "ColorStreamEnabled", typeof(bool), typeof(KinectSensorManager), new PropertyMetadata(true, (sender, args) => ((KinectSensorManager)sender).EnsureColorStreamState())); ColorFormatProperty = DependencyProperty.Register( "ColorFormat", typeof(ColorImageFormat), typeof(KinectSensorManager), new PropertyMetadata( ColorImageFormat.RgbResolution640x480Fps30, (sender, args) => ((KinectSensorManager)sender).EnsureColorStreamState())); DepthStreamEnabledProperty = DependencyProperty.Register( "DepthStreamEnabled", typeof(bool), typeof(KinectSensorManager), new PropertyMetadata(true, (sender, args) => ((KinectSensorManager)sender).EnsureDepthStreamState())); DepthFormatProperty = DependencyProperty.Register( "DepthFormat", typeof(DepthImageFormat), typeof(KinectSensorManager), new PropertyMetadata(DepthImageFormat.Resolution640x480Fps30, (sender, args) => ((KinectSensorManager)sender).EnsureDepthStreamState())); DepthRangeProperty = DependencyProperty.Register( "DepthRange", typeof(DepthRange), typeof(KinectSensorManager), new PropertyMetadata(DepthRange.Default, (sender, args) => ((KinectSensorManager)sender).EnsureDepthStreamState())); SkeletonStreamEnabledProperty = DependencyProperty.Register( "SkeletonStreamEnabled", typeof(bool), typeof(KinectSensorManager), new PropertyMetadata( false, (sender, args) => ((KinectSensorManager)sender).EnsureSkeletonStreamState())); SkeletonTrackingModeProperty = DependencyProperty.Register( "SkeletonTrackingMode", typeof(SkeletonTrackingMode), typeof(KinectSensorManager), new PropertyMetadata( SkeletonTrackingMode.Seated, (sender, args) => ((KinectSensorManager)sender).EnsureSkeletonStreamState())); SkeletonEnableTrackingInNearModeProperty = DependencyProperty.Register( "SkeletonEnableTrackingInNearMode", typeof(bool), typeof(KinectSensorManager), new PropertyMetadata( true, (sender, args) => ((KinectSensorManager)sender).EnsureSkeletonStreamState())); TransformSmoothParametersProperty = DependencyProperty.Register( "TransformSmoothParameters", typeof(TransformSmoothParameters), typeof(KinectSensorManager), new PropertyMetadata( default(TransformSmoothParameters), (sender, args) => ((KinectSensorManager)sender).EnsureSkeletonStreamState())); ElevationAngleProperty = DependencyProperty.Register( "ElevationAngle", typeof(int), typeof(KinectSensorManager), new PropertyMetadata(0, (sender, args) => ((KinectSensorManager)sender).EnsureElevationAngle(), CoerceElevationAngle)); ForceInfraredEmitterOffProperty = DependencyProperty.Register( "ForceInfraredEmitterOff", typeof(bool), typeof(KinectSensorManager), new PropertyMetadata(false, (sender, args) => ((KinectSensorManager)sender).EnsureForceInfraredEmitterOff())); AccelerometerProperty = DependencyProperty.Register( "Accelerometer", typeof(Vector4), typeof(KinectSensorManager)); }
static MenuItemEx() { IsMouseOverPropertyKey = (DependencyPropertyKey)typeof(UIElement).GetField( "IsMouseOverPropertyKey", BindingFlags.Static | BindingFlags.NonPublic) ?.GetValue(null) ?? throw new Exception("UIElement.IsMouseOverPropertyKey property not found"); }
public static void Override <TOwner>(this DependencyPropertyKey dpKey, PropertyMetadata typeMetadata) { dpKey.DependencyProperty.OverrideMetadata(typeof(TOwner), typeMetadata, dpKey); }
public static void Override(this DependencyPropertyKey dpKey, PropertyMetadata typeMetadata) { dpKey.DependencyProperty.OverrideMetadata(ExTool.GetDeclaringType(), typeMetadata, dpKey); }
public static void SetValue <T>(this DependencyObject dependencyObject, DependencyPropertyKey key, T value) { SetValue(dependencyObject, key, (object)value); }
public static T GetReadOnlyValue <T>(this DependencyObject depObj, DependencyPropertyKey propertyKey) { return((T)depObj.GetValue(propertyKey.DependencyProperty)); }
public static void SetReadOnlyValue(this DependencyObject depObj, DependencyPropertyKey propertyKey, object value) { depObj.SetValue(propertyKey, value); }
static ThumbExt() { IsDraggingPropertyKey = typeof(Thumb).GetField("IsDraggingPropertyKey", BindingFlags.NonPublic | BindingFlags.Static)? .GetValue(null) as DependencyPropertyKey; }
public DependencyPropertyRegistrator <T> RegisterReadOnly <TProperty>(Expression <Func <T, TProperty> > property, out DependencyPropertyKey propertyFieldKey, out DependencyProperty propertyField, TProperty defaultValue, Action <T, TProperty, TProperty> changedCallback, Func <T, TProperty, TProperty> coerceCallback, FrameworkPropertyMetadataOptions?frameworkOptions = null) { return(RegisterReadOnly(property, out propertyFieldKey, out propertyField, CreateMetadata(defaultValue, changedCallback, coerceCallback, frameworkOptions))); }
static ExpressionFloatingWindow() { ExpressionFloatingWindow.IsSizablePropertyKey = DependencyProperty.RegisterReadOnly("IsSizable", typeof(bool), typeof(ExpressionFloatingWindow), new PropertyMetadata(true)); ExpressionFloatingWindow.IsSizableProperty = ExpressionFloatingWindow.IsSizablePropertyKey.DependencyProperty; FrameworkElement.DefaultStyleKeyProperty.OverrideMetadata(typeof(ExpressionFloatingWindow), new FrameworkPropertyMetadata(typeof(ExpressionFloatingWindow))); }
public DependencyPropertyRegistrator <T> RegisterAttachedReadOnly <TOwner, TProperty>(Expression <Func <TOwner, TProperty> > getMethodName, out DependencyPropertyKey propertyFieldKey, out DependencyProperty propertyField, TProperty defaultValue, Action <TOwner, TProperty, TProperty> changedCallback, Func <TOwner, TProperty, TProperty> coerceCallback, FrameworkPropertyMetadataOptions?frameworkOptions = null) where TOwner : DependencyObject { return(RegisterAttachedReadOnly(getMethodName, out propertyFieldKey, out propertyField, CreateMetadata(defaultValue, changedCallback, coerceCallback, frameworkOptions))); }
static EventsTreeBase() { SelectedEventProperty = DependencyProperty.Register("SelectedEvent", typeof(IEvent), typeof(EventsTree), new PropertyMetadata(null, OnSelectedEventPropertyChanged)); HoveredEventPropertyKey = DependencyProperty.RegisterReadOnly("HoveredEvent", typeof(IEvent), typeof(EventsTree), new PropertyMetadata(null, OnHoveredEventPropertyChanged)); HoveredEventProperty = HoveredEventPropertyKey.DependencyProperty; }
static DockControl() { FocusableProperty.OverrideMetadata(typeof(DockControl), new FrameworkPropertyMetadata(BooleanBoxes.True)); DefaultStyleKeyProperty.OverrideMetadata(typeof(DockControl), new FrameworkPropertyMetadata(typeof(DockControl))); LeftDockTreePropertyKey = DependencyProperty.RegisterReadOnly("LeftDockTree", typeof(DockTree), typeof(DockControl), new FrameworkPropertyMetadata()); LeftDockTreeProperty = LeftDockTreePropertyKey.DependencyProperty; RightDockTreePropertyKey = DependencyProperty.RegisterReadOnly("RightDockTree", typeof(DockTree), typeof(DockControl), new FrameworkPropertyMetadata()); RightDockTreeProperty = RightDockTreePropertyKey.DependencyProperty; TopDockTreePropertyKey = DependencyProperty.RegisterReadOnly("TopDockTree", typeof(DockTree), typeof(DockControl), new FrameworkPropertyMetadata()); TopDockTreeProperty = TopDockTreePropertyKey.DependencyProperty; BottomDockTreePropertyKey = DependencyProperty.RegisterReadOnly("BottomDockTree", typeof(DockTree), typeof(DockControl), new FrameworkPropertyMetadata()); BottomDockTreeProperty = BottomDockTreePropertyKey.DependencyProperty; DocumentDockTreePropertyKey = DependencyProperty.RegisterReadOnly("DocumentDockTree", typeof(DockTree), typeof(DockControl), new FrameworkPropertyMetadata()); DocumentDockTreeProperty = DocumentDockTreePropertyKey.DependencyProperty; LeftDockTreeWidthProperty = DependencyProperty.Register("LeftDockTreeWidth", typeof(SplitterDistance), typeof(DockControl), new FrameworkPropertyMetadata(new SplitterDistance(1d / 3d, SplitterUnitType.Star), new PropertyChangedCallback(OnDockTreeSizeChanged))); RightDockTreeWidthProperty = DependencyProperty.Register("RightDockTreeWidth", typeof(SplitterDistance), typeof(DockControl), new FrameworkPropertyMetadata(new SplitterDistance(1d / 3d, SplitterUnitType.Star), new PropertyChangedCallback(OnDockTreeSizeChanged))); TopDockTreeHeightProperty = DependencyProperty.Register("TopDockTreeHeight", typeof(SplitterDistance), typeof(DockControl), new FrameworkPropertyMetadata(new SplitterDistance(1d / 3d, SplitterUnitType.Star), new PropertyChangedCallback(OnDockTreeSizeChanged))); BottomDockTreeHeightProperty = DependencyProperty.Register("BottomDockTreeHeight", typeof(SplitterDistance), typeof(DockControl), new FrameworkPropertyMetadata(new SplitterDistance(1d / 3d, SplitterUnitType.Star), new PropertyChangedCallback(OnDockTreeSizeChanged))); DockTreeZOrderProperty = DependencyProperty.Register("DockTreeZOrder", typeof(DockTreeZOrder), typeof(DockControl), new FrameworkPropertyMetadata(DockTreeZOrder.Default, new PropertyChangedCallback(OnDockTreeZOrderChanged))); FocusedItemPropertyKey = DependencyProperty.RegisterReadOnly("FocusedItem", typeof(DockItem), typeof(DockControl), new FrameworkPropertyMetadata(null)); ActiveItemPropertyKey = DependencyProperty.RegisterReadOnly("ActiveItem", typeof(DockItem), typeof(DockControl), new FrameworkPropertyMetadata(null)); ActiveDocumentPropertyKey = DependencyProperty.RegisterReadOnly("ActiveDocument", typeof(DockItem), typeof(DockControl), new FrameworkPropertyMetadata(null)); SelectedAutoHideItemPropertyKey = DependencyProperty.RegisterReadOnly("SelectedAutoHideItem", typeof(DockItem), typeof(DockControl), new FrameworkPropertyMetadata(null)); FocusedItemProperty = FocusedItemPropertyKey.DependencyProperty; ActiveItemProperty = ActiveItemPropertyKey.DependencyProperty; ActiveDocumentProperty = ActiveDocumentPropertyKey.DependencyProperty; SelectedAutoHideItemProperty = SelectedAutoHideItemPropertyKey.DependencyProperty; DefaultFloatingWindowSizeProperty = DependencyProperty.Register("DefaultFloatingWindowSize", typeof(Size), typeof(DockControl), new FrameworkPropertyMetadata(new Size(300, 300))); MaxUndoLevelProperty = DependencyProperty.Register("MaxUndoLevel", typeof(int), typeof(DockControl), new FrameworkPropertyMetadata(int.MaxValue, new PropertyChangedCallback(OnMaxUndoLevelChanged)), new ValidateValueCallback(ValidateMaxUndoLevel)); CanUndoPropertyKey = DependencyProperty.RegisterReadOnly("CanUndo", typeof(bool), typeof(DockControl), new FrameworkPropertyMetadata(BooleanBoxes.False, new PropertyChangedCallback(OnCanUndoCanRedoChanged))); CanUndoProperty = CanUndoPropertyKey.DependencyProperty; CanRedoPropertyKey = DependencyProperty.RegisterReadOnly("CanRedo", typeof(bool), typeof(DockControl), new FrameworkPropertyMetadata(BooleanBoxes.False, new PropertyChangedCallback(OnCanUndoCanRedoChanged))); CanRedoProperty = CanRedoPropertyKey.DependencyProperty; CommandBinding undoCommandBinding = new CommandBinding(DockCommands.Undo, new ExecutedRoutedEventHandler(OnUndoCommandExecuted), new CanExecuteRoutedEventHandler(CanExecuteUndoCommand)); CommandBinding redoCommandBinding = new CommandBinding(DockCommands.Redo, new ExecutedRoutedEventHandler(OnRedoCommandExecuted), new CanExecuteRoutedEventHandler(CanExecuteRedoCommand)); CommandManager.RegisterClassCommandBinding(typeof(DockControl), undoCommandBinding); CommandManager.RegisterClassCommandBinding(typeof(DockControl), redoCommandBinding); }
static ImageZoomBoxPanel() { // WPF properties PaddingProperty = DependencyProperty.Register( "Padding", typeof(Thickness), typeof(ImageZoomBoxPanel), new FrameworkPropertyMetadata( new Thickness(DEFAULTLEFTRIGHTMARGIN, DEFAULTTOPBOTTOMMARGIN, DEFAULTLEFTRIGHTMARGIN, DEFAULTTOPBOTTOMMARGIN), FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.Journal, null, null), null); CenterContentProperty = DependencyProperty.Register( "CenterContent", typeof(bool), typeof(ImageZoomBoxPanel), new FrameworkPropertyMetadata(true, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.Journal, null, null), null); MinZoomProperty = DependencyProperty.Register( "MinZoom", typeof(double), typeof(ImageZoomBoxPanel), new FrameworkPropertyMetadata(1.0, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.Journal, PropertyChanged_Zoom, CoerceMinZoom), new ValidateValueCallback(ImageZoomBoxPanel.ValidateIsPositiveNonZero)); MaxZoomProperty = DependencyProperty.Register( "MaxZoom", typeof(double), typeof(ImageZoomBoxPanel), new FrameworkPropertyMetadata(1000.0, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.Journal, PropertyChanged_Zoom, CoerceMaxZoom), new ValidateValueCallback(ImageZoomBoxPanel.ValidateIsPositiveNonZero)); ZoomProperty = DependencyProperty.Register( "Zoom", typeof(double), typeof(ImageZoomBoxPanel), new FrameworkPropertyMetadata(100.0, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.Journal, PropertyChanged_Zoom, CoerceZoom), new ValidateValueCallback(ImageZoomBoxPanel.ValidateIsPositiveNonZero)); CanIncreaseZoomPropertyKey = DependencyProperty.RegisterReadOnly( "CanIncreaseZoom", typeof(bool), typeof(ImageZoomBoxPanel), new FrameworkPropertyMetadata(false, null, null)); CanDecreaseZoomPropertyKey = DependencyProperty.RegisterReadOnly( "CanDecreaseZoom", typeof(bool), typeof(ImageZoomBoxPanel), new FrameworkPropertyMetadata(false, null, null)); CanRotateKey = DependencyProperty.RegisterReadOnly( "CanRotate", typeof(bool), typeof(ImageZoomBoxPanel), new FrameworkPropertyMetadata(true, null, null)); ZoomTickProperty = DependencyProperty.Register( "ZoomTick", typeof(double), typeof(ImageZoomBoxPanel), new FrameworkPropertyMetadata(50.0, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.Journal, PropertyChanged_Zoom, CoerceZoomTick), null); MinZoomTickProperty = DependencyProperty.Register( "MinZoomTick", typeof(double), typeof(ImageZoomBoxPanel), new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.Journal, PropertyChanged_Zoom, CoerceMinZoomTick), null); MaxZoomTickProperty = DependencyProperty.Register( "MaxZoomTick", typeof(double), typeof(ImageZoomBoxPanel), new FrameworkPropertyMetadata(100.0, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.Journal, PropertyChanged_Zoom, CoerceMaxZoomTick), null); ZoomIncrementProperty = DependencyProperty.Register( "ZoomIncrement", typeof(double), typeof(ImageZoomBoxPanel), new FrameworkPropertyMetadata(20.0), new ValidateValueCallback(ImageZoomBoxPanel.ValidateIsPositiveNonZero)); RotateIncrementProperty = DependencyProperty.Register( "RotateIncrement", typeof(double), typeof(ImageZoomBoxPanel), new FrameworkPropertyMetadata(15.0, null, CoerceRotateIncrement), new ValidateValueCallback(ImageZoomBoxPanel.ValidateIsPositiveNonZero)); WheelZoomDeltaProperty = DependencyProperty.Register( "WheelZoomDelta", typeof(double), typeof(ImageZoomBoxPanel), new FrameworkPropertyMetadata(10.0), new ValidateValueCallback(ImageZoomBoxPanel.ValidateIsPositiveNonZero)); WheelModeProperty = DependencyProperty.Register( "WheelMode", typeof(ImageZoomBoxPanel.eWheelMode), typeof(ImageZoomBoxPanel), new FrameworkPropertyMetadata(ImageZoomBoxPanel.eWheelMode.Zoom, PropertyChanged_AMode), null); ZoomModeProperty = DependencyProperty.Register( "ZoomMode", typeof(ImageZoomBoxPanel.eZoomMode), typeof(ImageZoomBoxPanel), new FrameworkPropertyMetadata(ImageZoomBoxPanel.eZoomMode.FitPage, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.Journal, PropertyChanged_AMode, null), null); MouseModeProperty = DependencyProperty.Register( "MouseMode", typeof(ImageZoomBoxPanel.eMouseMode), typeof(ImageZoomBoxPanel), new FrameworkPropertyMetadata(ImageZoomBoxPanel.eMouseMode.None, PropertyChanged_AMode), null); AnimationsProperty = DependencyProperty.Register( "Animations", typeof(bool), typeof(ImageZoomBoxPanel), new FrameworkPropertyMetadata(true, null), null); LockContentProperty = DependencyProperty.Register( "LockContent", typeof(bool), typeof(ImageZoomBoxPanel), new FrameworkPropertyMetadata(false, null), null); //----------------------------------------------------------------- // Commands CommandManager.RegisterClassCommandBinding(typeof(ImageZoomBoxPanel), new CommandBinding(NavigationCommands.IncreaseZoom, ExecutedEventHandler_IncreaseZoom, CanExecuteEventHandler_IfCanIncreaseZoom)); CommandManager.RegisterClassCommandBinding(typeof(ImageZoomBoxPanel), new CommandBinding(NavigationCommands.DecreaseZoom, ExecutedEventHandler_DecreaseZoom, CanExecuteEventHandler_IfCanDecreaseZoom)); InputGestureCollection rotateInputGestures = new InputGestureCollection(); rotateInputGestures.Add(new KeyGesture(Key.R, ModifierKeys.Control)); rotateClockwiseCommand = new RoutedUICommand("Rotate Clockwise", "RotateClockwise", typeof(ImageZoomBoxPanel), rotateInputGestures); CommandManager.RegisterClassCommandBinding(typeof(ImageZoomBoxPanel), new CommandBinding(rotateClockwiseCommand, ExecutedEventHandler_RotateClockwise, CanExecuteEventHandler_IfHasContent)); InputGestureCollection rotateCounterInputGestures = new InputGestureCollection(); rotateCounterInputGestures.Add(new KeyGesture(Key.R, ModifierKeys.Alt)); rotateCounterclockwiseCommand = new RoutedUICommand("Rotate Counterclockwise", "RotateCounterclockwise", typeof(ImageZoomBoxPanel), rotateCounterInputGestures); CommandManager.RegisterClassCommandBinding(typeof(ImageZoomBoxPanel), new CommandBinding(rotateCounterclockwiseCommand, ExecutedEventHandler_RotateCounterclockwise, CanExecuteEventHandler_IfHasContent)); InputGestureCollection rotateHomeInputGestures = new InputGestureCollection(); rotateHomeInputGestures.Add(new KeyGesture(Key.Home, ModifierKeys.None)); rotateHomeCommand = new RoutedUICommand("Rotate Home", "RotateHome", typeof(ImageZoomBoxPanel), rotateHomeInputGestures); CommandManager.RegisterClassCommandBinding(typeof(ImageZoomBoxPanel), new CommandBinding(rotateHomeCommand, ExecutedEventHandler_RotateHome, CanExecuteEventHandler_IfHasContent)); InputGestureCollection rotateReverseInputGestures = new InputGestureCollection(); rotateReverseInputGestures.Add(new KeyGesture(Key.End, ModifierKeys.None)); rotateReverseCommand = new RoutedUICommand("Rotate Reverse", "RotateReverse", typeof(ImageZoomBoxPanel), rotateReverseInputGestures); CommandManager.RegisterClassCommandBinding(typeof(ImageZoomBoxPanel), new CommandBinding(rotateReverseCommand, ExecutedEventHandler_RotateReverse, CanExecuteEventHandler_IfHasContent)); }