static ModernContextMenuItem() { CommandProperty.OverrideMetadata(typeof(ModernContextMenuItem), new FrameworkPropertyMetadata(null, CommandPropertyChangedCallback, CommandPropertyCoerceValueCallback)); CommandParameterProperty.OverrideMetadata(typeof(ModernContextMenuItem), new FrameworkPropertyMetadata(null, CommandParameterPropertyChangedCallback)); }
public TValue GetItem <TValue>(Expression <Func <TParameter, TValue> > getItem) { var(_, _, itemInfo) = MemberVisitor.GetMemberInfo(getItem); var itemMetadata = CommandParameterProperty.Create((PropertyInfo)itemInfo); var(uri, metadata) = ItemRequestFactory.CreateItemRequest(itemMetadata); var item = _args.GetAsync(uri, metadata).GetAwaiter().GetResult(); if (item.Exists) { if (itemMetadata.IsCollection) { return(item.DeserializeJsonAsync <TValue>().GetAwaiter().GetResult()); } else { var values = item.DeserializeJsonAsync <List <TValue> >().GetAwaiter().GetResult(); if (((PropertyInfo)itemInfo).PropertyType == typeof(bool)) { return (values.Any() ? values.Single() : itemMetadata.DefaultValue is TValue defaultValue ? defaultValue : (TValue)(object)true); } else { return (values.Any() ? values.Single() : itemMetadata.DefaultValue is TValue defaultValue ? defaultValue : default);
/// <summary> /// Overriding to setup state. /// </summary> public override void OnApplyTemplate() { base.OnApplyTemplate(); if (BackgroundProperty.IsUnsetValue(this)) { Background = MetroTileFrame.GetBackgroundBrushFromTileColor(TileColor); } if (CommandParameterProperty.IsUnsetValue(this)) { CommandParameter = this; } SetWidth(Type); var scaleTransform = GetTemplateChild("ScaleTransform") as ScaleTransform; if (scaleTransform != null) { scaleTransform.Bind(ScaleTransform.CenterXProperty, this, ActualWidthProperty, BindingMode.OneWay, _MultiplicationConverter, 0.5); scaleTransform.Bind(ScaleTransform.CenterYProperty, this, ActualHeightProperty, BindingMode.OneWay, _MultiplicationConverter, 0.5); } var content3d = GetTemplateChild("Content3D") as Content3D; if (content3d != null) { var transform = GetTemplateChild("RotateRightInwards") as RotateTransform3D; if (transform != null) { transform.Bind(RotateTransform3D.CenterXProperty, content3d, Content3D.ThreeDBoundsXProperty); } transform = GetTemplateChild("RotateLeftInwards") as RotateTransform3D; if (transform != null) { transform.Bind(RotateTransform3D.CenterXProperty, content3d, Content3D.ThreeDBoundsXProperty, BindingMode.OneWay, _MultiplicationConverter, -1); } transform = GetTemplateChild("RotateTopInwards") as RotateTransform3D; if (transform != null) { transform.Bind(RotateTransform3D.CenterYProperty, content3d, Content3D.ThreeDBoundsYProperty); } transform = GetTemplateChild("RotateBottomInwards") as RotateTransform3D; if (transform != null) { transform.Bind(RotateTransform3D.CenterYProperty, content3d, Content3D.ThreeDBoundsYProperty, BindingMode.OneWay, _MultiplicationConverter, -1); } } _FramesPresenter = GetTemplateChild("FramesPresenter") as MetroTileFramesPresenter; if (_FramesPresenter != null) { this.Bind(HasFramesProperty, _FramesPresenter, "HasItems"); } }
set => SetValue(CommandParameterProperty, value);
// arg:///file/f?&position=1 public static (UriString Uri, IImmutableSession Metadata) CreateItemRequest(CommandParameterProperty item) { var queryParameters = new (SoftString Key, SoftString Value)[]
static RadioButtonWithImage() { CommandProperty.OverrideMetadata(typeof(RadioButtonWithImage), new FrameworkPropertyMetadata(OnCommandPropertyChanged)); CommandParameterProperty.OverrideMetadata(typeof(RadioButtonWithImage), new FrameworkPropertyMetadata(OnCommandPropertyChanged)); }
static AutoInvalidateButton() { CommandProperty.OverrideMetadata(typeof(AutoInvalidateButton), new FrameworkPropertyMetadata(OnCommandChanged)); CommandParameterProperty.OverrideMetadata(typeof(AutoInvalidateButton), new FrameworkPropertyMetadata(OnCommandParameterChanged)); }