public ColorPick() { InitializeComponent(); KeepPreviewColor = false; this.m_cbxColorsBox.ItemsSource = typeof(Colors).GetProperties(); for (int i = 0; i < this.m_cbxColorsBox.Items.Count; i++) { var varObj = this.m_cbxColorsBox.Items[i]; if ("Red" == ((PropertyInfo)varObj).Name) { this.m_cbxColorsBox.SelectedIndex = i; break; } } #region Binding Color to sliders MultiBinding mb = new MultiBinding(); mb.Converter = new RgbToColorConverter(); mb.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged; mb.Mode = BindingMode.TwoWay; Binding bb = new Binding("Value"); bb.ElementName = "R"; bb.Mode = BindingMode.TwoWay; mb.Bindings.Add(bb); bb = new Binding("Value"); bb.ElementName = "G"; bb.Mode = BindingMode.TwoWay; mb.Bindings.Add(bb); bb = new Binding("Value"); bb.ElementName = "B"; bb.Mode = BindingMode.TwoWay; mb.Bindings.Add(bb); this.SetBinding(ColorProperty, mb); #endregion }
/// <summary> /// 创建简单的 GridViewColumn 对象 /// </summary> /// <param name="header"></param> /// <param name="paths"></param> /// <param name="parameter"></param> /// <returns></returns> public static GridViewColumn CreateColumn(string header, string[] paths, string parameter) { MultiBinding Binds = new MultiBinding(); Binds.ConverterParameter = parameter; Binds.Converter = new MultiStringConverter(); for (int i = 0; i < paths.Length; i++) { Binds.Bindings.Add(new Binding(paths[i])); } GridViewColumn column = new GridViewColumn() { Header = header, DisplayMemberBinding = Binds, }; return(column); }
public static Brush GetPressedRevealBrush(UIElement target) { var gradientStops = new GradientStopCollection( new[] { new GradientStop(Color.FromArgb(30, 255, 255, 255), 0), new GradientStop(Color.FromArgb(40, 255, 255, 255), 0), new GradientStop(Colors.Transparent, 1) }); RadialGradientBrush brush = new(gradientStops) { MappingMode = BrushMappingMode.Absolute, Opacity = 0.0, RadiusX = 200.0, RadiusY = 200.0 }; var binding = new MultiBinding { Converter = new RelativePositionConverter() }; binding.Bindings.Add(new Binding() { Source = target, Path = new PropertyPath(RevealBrushHelper.RootObjectProperty) }); binding.Bindings.Add(new Binding() { Source = target }); binding.Bindings.Add(new Binding() { Source = target, Path = new PropertyPath(RevealBrushHelper.MousePositionProperty) }); BindingOperations.SetBinding(brush, RadialGradientBrush.CenterProperty, binding); BindingOperations.SetBinding(brush, RadialGradientBrush.GradientOriginProperty, binding); RevealBrushHelper.SetRevealBrush(target, brush); return(brush); }
public MediaBrowser() { InitializeComponent(); ((FrameworkElement)this.Content).DataContext = this; MultiBinding mb = new MultiBinding() { Converter = new MediaBrowserFilterConverter(this) }; mb.Bindings.Add(new Binding("SourceData.PlaylistItems") { Source = this }); mb.Bindings.Add(new Binding("Text") { Source = textBox }); BindingOperations.SetBinding(this, SelectedDataProperty, mb); }
private static void Bind(DependencyObject target, DependencyProperty prop, IMultiValueConverter converter, params System.Linq.Expressions.Expression[] expressions) { var multiBinding = new MultiBinding(); multiBinding.Converter = converter; foreach (var expression in expressions) { var targetAndMember = expression.GetTargetAndMember(); var bindingSource = targetAndMember.Item1; var member = targetAndMember.Item2; var binding = new Binding(member.Name); binding.Source = bindingSource; multiBinding.Bindings.Add(binding); } BindingOperations.SetBinding(target, prop, multiBinding); }
public override void OnApplyTemplate() { base.OnApplyTemplate(); //CloseButton var closeButton = GetTemplateChild("CloseButton") as Button; var decrementButton = GetTemplateChild("DecrementButton") as Button; var incrementButton = GetTemplateChild("IncrementButton") as Button; var panelButtons = GetTemplateChild("panelButtons") as StackPanel; var lblPersons = GetTemplateChild("lblPersons") as TextBlock; if (closeButton != null) { closeButton.Click += new RoutedEventHandler(closeButton_Click); decrementButton.Click += new RoutedEventHandler(decrementButton_Click); incrementButton.Click += new RoutedEventHandler(incrementButton_Click); MultiBinding multiBinding = new MultiBinding(); multiBinding.Converter = new BoolToVisibilityMultiBinding(); Binding result = new Binding("ReadOnly"); result.Source = this.Owner; multiBinding.Bindings.Add(result); result = new Binding("ReadOnly"); multiBinding.Bindings.Add(result); //result.Source = this.Owner; //result.Converter = new NegateBoolToVisibilityConverter(); panelButtons.SetBinding(Calendar.VisibilityProperty, multiBinding); //multiBinding = new MultiBinding(); //multiBinding.Converter = new ReadOnlyToVisibilityMultiBinding(); //result = new Binding("ReadOnly"); //result.Source = this.Owner; //multiBinding.Bindings.Add(result); result = new Binding("ReadOnly"); //multiBinding.Bindings.Add(result); //result.Source = this.Owner; result.Converter = new BooleanToVisibilityConverter(); lblPersons.SetBinding(Calendar.VisibilityProperty, result); } if (owner.SelectedAppointment == this.Content) { SetSelection(true); } }
public override object ProvideValue(IServiceProvider serviceProvider) { var multiBinding = new MultiBinding(); Binding.Mode = Mode; multiBinding.Bindings.Add(Binding); if (ConverterParameter != null) { ConverterParameter.Mode = BindingMode.OneWay; multiBinding.Bindings.Add(ConverterParameter); } var adapter = new MultiValueConverterAdapter { Converter = Converter }; multiBinding.Converter = adapter; return(multiBinding.ProvideValue(serviceProvider)); }
/// <summary> /// Create a new enum text box. /// </summary> public EnumTextBox() { MultiBinding textBinding = new MultiBinding() { Converter = new EnumLengthConverter(this) }; textBinding.Bindings.Add(new Binding("Length") { Source = this }); textBinding.Bindings.Add(new Binding("Unit") { Source = this }); this.Mask = @"((\d{1,3}(,\d\d\d)*)|\d+)(\.\d+)?|\.\d+ +"; this.SetBinding(EnumTextBox.TextProperty, textBinding); }
public void TestStringFormat() { var property = BindableProperty.Create("foo", typeof(string), typeof(MockBindable), null); var bindable = new MockBindable(); var multibinding = new MultiBinding { Bindings = { new Binding("foo"), new Binding("bar"), new Binding("baz"), }, StringFormat = "{0} - {1} - {2}" }; Assert.DoesNotThrow(() => bindable.SetBinding(property, multibinding)); Assert.DoesNotThrow(() => bindable.BindingContext = new { foo = "FOO", bar = 42, baz = "BAZ" }); Assert.That(bindable.GetValue(property), Is.EqualTo("FOO - 42 - BAZ")); }
public void UpdateValueSource(IEnumerable sourceItems, string path) { BindingBase binding = null; if (sourceItems != null && path != null) { MultiBinding multiBinding = new MultiBinding(); multiBinding.Converter = new BlankMultiValueConverter(); foreach (object sourceItem in sourceItems) { multiBinding.Bindings.Add(new Binding(path) { Source = sourceItem }); } binding = multiBinding; } UpdateBinding(binding); }
private void InitializeCommand() { this.submitButton.Command = this.SubmitCommand; // 绑定快捷键 this.SubmitCommand.InputGestures.Add(new KeyGesture(Key.S, ModifierKeys.Control)); // 绑定命令目标 this.submitButton.CommandTarget = this.messageTextBox; // 使用 MultiBinding 给命令传递多个参数 var multiBinding = new MultiBinding(); multiBinding.Converter = new MultiParameterValueConverter(); multiBinding.Bindings.Add(new Binding(nameof(this.messageTextBox.Text)) { Source = this.messageTextBox }); multiBinding.Bindings.Add(new Binding(nameof(this.submitButton.Name)) { Source = this.submitButton }); this.submitButton.SetBinding(Button.CommandParameterProperty, multiBinding); // 增加命令绑定 var commandBinding = new CommandBinding() { Command = this.SubmitCommand }; /* PreviewCanExecute 和 CanExecute 事件由框架自动触发,且频率较高,会对性能造成影响,使用时务必谨慎 * // 是否允许执行前事件 * commandBinding.PreviewCanExecute += (s, e) => { e.Handled = true; }; * // 执行前事件 * commandBinding.PreviewExecuted += (s, e) => { e.Handled = true; }; */ // 是否允许执行事件(与事件源的 Enabled 属性关联) commandBinding.CanExecute += this.CommandBinding_CanExecute; // 执行后事件 commandBinding.Executed += this.CommandBinding_Executed; // 将命令绑定添加到外围容器控件 this.dockPanel.CommandBindings.Add(commandBinding); }
public override object ProvideValue(IServiceProvider serviceProvider) { var pvt = serviceProvider.GetService(typeof(IProvideValueTarget)) as IProvideValueTarget; var target = pvt.TargetObject as DependencyObject; var bgColor = Color.FromArgb(0, this.Color.R, this.Color.G, this.Color.B); var brush = new RadialGradientBrush(this.Color, bgColor); brush.MappingMode = BrushMappingMode.Absolute; brush.RadiusX = this.Size; brush.RadiusY = this.Size; var opacityBinding = new Binding("Opacity") { Source = target, Path = new PropertyPath(PointerTracker.IsEnterProperty), Converter = new OpacityConverter(), ConverterParameter = this.Opacity }; BindingOperations.SetBinding(brush, RadialGradientBrush.OpacityProperty, opacityBinding); var binding = new MultiBinding(); binding.Converter = new RelativePositionConverter(); binding.Bindings.Add(new Binding() { Source = target, Path = new PropertyPath(PointerTracker.RootObjectProperty) }); binding.Bindings.Add(new Binding() { Source = target }); binding.Bindings.Add(new Binding() { Source = target, Path = new PropertyPath(PointerTracker.PositionProperty) }); BindingOperations.SetBinding(brush, RadialGradientBrush.CenterProperty, binding); BindingOperations.SetBinding(brush, RadialGradientBrush.GradientOriginProperty, binding); return(brush); }
private object BindDictionary(IServiceProvider serviceProvider) { string define = _define ?? GetDefine(_target); string value = _property.Name; Binding binding = new Binding("Dictionary") { Source = LanguageContext.Instance, Mode = BindingMode.TwoWay }; LanguageConverter converter = new LanguageConverter(define, value); if (_parameters.Count == 0) { binding.Converter = converter; object realvalue = binding.ProvideValue(serviceProvider); return(realvalue); } else { MultiBinding multiBinding = new MultiBinding { Mode = BindingMode.TwoWay, Converter = converter }; multiBinding.Bindings.Add(binding); if (string.IsNullOrEmpty(define)) { Binding defineBinding = _parameters[0] as Binding; if (defineBinding == null) { throw new ArgumentException("Define Binding parameter must be the first, and of type Binding"); } } foreach (Binding parameter in _parameters) { multiBinding.Bindings.Add(parameter); } object realvalue = multiBinding.ProvideValue(serviceProvider); return(realvalue); } }
protected void SetupGeometry() { BindingOperations.ClearAllBindings(this); StoredGeometry = new LineGeometry(); if ((StartObject != null) && (EndObject != null) && (!string.IsNullOrEmpty(StartProperty)) && (!string.IsNullOrEmpty(EndProperty))) { // Must use BindingOperations since Geometry doesn't have SetBinding. // Why? Performance penalty? Binding b1 = new Binding(StartProperty) { Source = StartObject }; BindingOperations.SetBinding(StoredGeometry, LineGeometry.StartPointProperty, b1); Binding b2 = new Binding(EndProperty) { Source = EndObject }; BindingOperations.SetBinding(StoredGeometry, LineGeometry.EndPointProperty, b2); // If any of the nodes is hidden or collapsed, we shouldn't see the line either. MultiBinding visBindingGroup = new MultiBinding(); visBindingGroup.Bindings.Add(new Binding { Source = StartObject, Path = new PropertyPath("Visibility") }); visBindingGroup.Bindings.Add(new Binding { Source = EndObject, Path = new PropertyPath("Visibility") }); visBindingGroup.Converter = new ConnectedVisibilityConverter(); this.SetBinding(VisibilityProperty, visBindingGroup); } }
private void createBindingsForPositioning() { MultiBinding multiBinding = new MultiBinding(); multiBinding.Converter = m_VToYConverter; multiBinding.Bindings.Add(new Binding("V") { Source = curveEditPoint }); multiBinding.Bindings.Add(new Binding("MinV") { Source = CurveEditor }); multiBinding.Bindings.Add(new Binding("MaxV") { Source = CurveEditor }); multiBinding.Bindings.Add(new Binding("ActualHeight") { Source = CurveEditor }); BindingOperations.SetBinding(XTranslateTransform, TranslateTransform.YProperty, multiBinding); MultiBinding multiBinding2 = new MultiBinding(); multiBinding2.Converter = m_UToXConverter; multiBinding2.Bindings.Add(new Binding("U") { Source = curveEditPoint }); multiBinding2.Bindings.Add(new Binding("UScale") { Source = CurveEditor }); multiBinding2.Bindings.Add(new Binding("UOffset") { Source = CurveEditor }); BindingOperations.SetBinding(XTranslateTransform, TranslateTransform.XProperty, multiBinding2); }
Style CreateStyle() { var style = new Style(); var multibinding = new MultiBinding { Converter = new SimpleMultiValueConverter() }; multibinding.Bindings.Add(new Binding("FirstName")); multibinding.Bindings.Add(new Binding("LstName")); //purposefully misspelled var trigger = new DataTrigger(); trigger.Binding = multibinding; trigger.Value = "Rob Eisenberg"; style.Triggers.Add(trigger); return(style); }
private static void AddSimpleMultiBinding(Customer customer, OutputSink outputSink, BindingManager bindingManager) { #region Simple MultiBinding var binding = new MultiBinding(outputSink, "Output"); binding.Sources.Add(new Binding(null, null, customer, "Name")); binding.Sources.Add(new Binding(null, null, customer, "Gender")); binding.Sources.Add(new Binding(null, null, customer, "BirthDate")); binding.Sources.Add(new Binding(null, null, customer, "Address.Line1")); binding.Sources.Add(new Binding(null, null, customer, "Address.Line2")); binding.Sources.Add(new Binding(null, null, customer, "Address.Line3")); binding.Sources.Add(new Binding(null, null, customer, "Address.Line4")); binding.Sources.Add(new Binding(null, null, customer, "Address.PostCode")); binding.Mode = BindingMode.OneWayToTarget; binding.Converter = new OutputConverter(); bindingManager.Bindings.Add(binding); #endregion }
/// <summary> /// Update the given target when the culture changes /// </summary> /// <param name="target">The target to update</param> protected override void UpdateTarget(object target) { if (this.IsBound) { var element = target as FrameworkElement; if (element != null) { var value = GetValue(); MultiBinding wrapper = CreateMultiBindingWrapper(value); element.SetBinding(base.TargetProperty as DependencyProperty, wrapper); } } else { base.UpdateTarget(target); } }
Style CreateStyle() { var style = new Style(); var multibinding = new MultiBinding { Converter = new SimpleMultiValueConverter() }; multibinding.Bindings.Add(new Binding("FirstName")); multibinding.Bindings.Add(new Binding("LstName")); //purposefully misspelled style.Setters.Add( new Setter( TextBlock.FontFamilyProperty, multibinding ) ); return(style); }
/// <summary> /// Generate a wrapper on a hierarchy of binding nodes instance /// The wrapper is a <see cref="MultiBinding"/> instance with a converter /// that process the bindings resolved value using the given nodes /// </summary> /// <param name="value"></param> /// <returns>A <see cref="MultiBinding"/> instance</returns> private MultiBinding CreateMultiBindingWrapper(object value) { BindingNode root = null; var bindings = new Collection <Binding>(); ProcessBindings(value, ref root, ref bindings); var wrapper = new MultiBinding(); foreach (var binding in bindings) { wrapper.Bindings.Add(binding); } wrapper.TargetNullValue = GetTargetNullValue(this); wrapper.Converter = new BindingNodeConverter(root); return(wrapper); }
public void TestConverterWithStringFormat() { var property = BindableProperty.Create("foo", typeof(string), typeof(MockBindable), null); var bindable = new MockBindable(); var multibinding = new MultiBinding { Bindings = { new Binding("foo"), new Binding("bar", stringFormat: "{0:000}"), new Binding("baz") }, Converter = new StringConcatenationConverter(), StringFormat = "Hello {0}" }; Assert.DoesNotThrow(() => bindable.SetBinding(property, multibinding)); Assert.DoesNotThrow(() => bindable.BindingContext = new { foo = "FOO", bar = 42, baz = "BAZ" }); Assert.That(bindable.GetValue(property), Is.EqualTo("Hello FOO 042 BAZ")); }
/// <summary> /// Create a new enum text box. /// </summary> public EnumTextBox(Type type) { MultiBinding textBinding = new MultiBinding() { Converter = new EnumLengthConverter(this) }; textBinding.Bindings.Add(new Binding("Length") { Source = this }); textBinding.Bindings.Add(new Binding("Unit") { Source = this }); this.Type = type; this.SetBinding(EnumTextBox.TextProperty, textBinding); }
/// <inheritdoc /> public GestureFromManagerToCommand() { var c = new ConfigNameAndManagerToGestureMultiConverter(); var b = new MultiBinding() { Converter = c }; b.Bindings.Add(new Binding(nameof(ConfigName)) { Source = this, Mode = BindingMode.OneWay }); b.Bindings.Add(new Binding(nameof(Manager)) { Source = this, Mode = BindingMode.OneWay }); BindingOperations.SetBinding(this, GestureProperty, b); }
protected virtual void MultiBindingLabel <T>(Control control, Expression <Func <T> > action1, Expression <Func <T> > action2) { Binding binding1 = new Binding(GetPropertyPath(action1)) { Source = this }; Binding binding2 = new Binding(GetPropertyPath(action2)) { Source = this }; MultiBinding mb = new MultiBinding(); mb.Bindings.Add(binding1); mb.Bindings.Add(binding2); mb.Converter = new LabelMultiValueConverter(); control.SetBinding(Label.ContentProperty, mb); }
private void DisplaySelectionCuboidsDimensions() { foreach (Cuboid cuboid in CuboidsSelection) { TextBlock textBlock = new TextBlock { VerticalAlignment = VerticalAlignment.Center, FontWeight = FontWeights.DemiBold }; MultiBinding multiBinding = new MultiBinding() { Converter = new CuboidDimensionsToStringConverter() }; multiBinding.Bindings.Add(new Binding("Width") { Source = cuboid, Mode = BindingMode.OneWay }); multiBinding.Bindings.Add(new Binding("Depth") { Source = cuboid, Mode = BindingMode.OneWay }); multiBinding.Bindings.Add(new Binding("Height") { Source = cuboid, Mode = BindingMode.OneWay }); textBlock.SetBinding(TextBlock.TextProperty, multiBinding); int left = Settings.LargeFactor * (Settings.MaxSize + 2); int top = 2 * Settings.LargeFactor * (cuboid.SelectId - 1); Border border = new Border { Height = Settings.LargeFactor, Margin = new Thickness(5, 0, 0, 0), Child = textBlock }; Canvas.SetLeft(border, left); Canvas.SetTop(border, top); MainCanvas.Children.Add(border); } }
public SequenceDiagram() { InitializeComponent(); ViewModel = new SequenceDiagramViewModel(); _orientationLines = new List <Line>(); _currentOrientationLine = null; _isControlPressed = false; _orientationLineXBinding = new MultiBinding(); Binding diagnoseOutputItemsControlActualWidthBinding = new Binding(); diagnoseOutputItemsControlActualWidthBinding.ElementName = "DiagnoseOutputItemsControl"; diagnoseOutputItemsControlActualWidthBinding.Path = new PropertyPath("ActualWidth"); _orientationLineXBinding.Bindings.Add(diagnoseOutputItemsControlActualWidthBinding); Binding scrollViewerViewportWidthBinding = new Binding(); scrollViewerViewportWidthBinding.ElementName = "ScrollViewer"; scrollViewerViewportWidthBinding.Path = new PropertyPath("ViewportWidth"); _orientationLineXBinding.Bindings.Add(scrollViewerViewportWidthBinding); _orientationLineXBinding.Converter = new MaxConverter(); _orientationLineYBinding = new MultiBinding(); Binding lineDurationBinding = new Binding(); lineDurationBinding.RelativeSource = new RelativeSource(RelativeSourceMode.Self); lineDurationBinding.Path = new PropertyPath("Tag"); _orientationLineYBinding.Bindings.Add(lineDurationBinding); Binding lineZoomBinding = new Binding(); lineZoomBinding.ElementName = "ZoomSlider"; lineZoomBinding.Path = new PropertyPath("Value"); _orientationLineYBinding.Bindings.Add(lineZoomBinding); Binding sequenceDiagramUserControlHeightBinding = new Binding(); sequenceDiagramUserControlHeightBinding.ElementName = "SequenceDiagramUserControl"; sequenceDiagramUserControlHeightBinding.Path = new PropertyPath("ActualHeight"); _orientationLineYBinding.Bindings.Add(sequenceDiagramUserControlHeightBinding); _orientationLineYBinding.Converter = new DurationToHeightConverter(); MainGrid.ContextMenu = null; DiagnoseOutputItemsControl.LayoutUpdated += new EventHandler(DiagnoseOutputItemsControlOnLayoutUpdated); }
/// <summary> /// Returns true if the binding (or any part of it) is OneWay. /// </summary> internal static bool IsOneWay(BindingBase bindingBase) { if (bindingBase == null) { return(false); } // If it is a standard Binding, then check if it's Mode is OneWay Binding binding = bindingBase as Binding; if (binding != null) { return(binding.Mode == BindingMode.OneWay); } // A multi-binding can be OneWay as well MultiBinding multiBinding = bindingBase as MultiBinding; if (multiBinding != null) { return(multiBinding.Mode == BindingMode.OneWay); } // A priority binding is a list of bindings, if any are OneWay, we'll call it OneWay PriorityBinding priBinding = bindingBase as PriorityBinding; if (priBinding != null) { Collection <BindingBase> subBindings = priBinding.Bindings; int count = subBindings.Count; for (int i = 0; i < count; i++) { if (IsOneWay(subBindings[i])) { return(true); } } } return(false); }
public override object ProvideValue(IServiceProvider serviceProvider) { var target = ((IProvideValueTarget)serviceProvider.GetService(typeof(IProvideValueTarget)))?.TargetObject as DependencyObject; var bgColor = Color.FromArgb(0, this.Color.R, this.Color.G, this.Color.B); var brush = new RadialGradientBrush(this.Color, bgColor) { MappingMode = BrushMappingMode.Absolute, RadiusX = this.Size, RadiusY = this.Size }; var opacityBinding = new Binding("Opacity") { Source = target, Path = new PropertyPath(BordersBesideMouse.IsMouseOverProperty), Converter = new IsMouseOverToOpacityConverter() }; var binding = new MultiBinding { Converter = new RelativePositionConverter() }; binding.Bindings.Add(new Binding() { Source = target, Path = new PropertyPath(BordersBesideMouse.RootProperty) }); binding.Bindings.Add(new Binding() { Source = target }); binding.Bindings.Add(new Binding() { Source = target, Path = new PropertyPath(BordersBesideMouse.GradientPositionProperty) }); BindingOperations.SetBinding(brush, RadialGradientBrush.CenterProperty, binding); BindingOperations.SetBinding(brush, RadialGradientBrush.GradientOriginProperty, binding); BindingOperations.SetBinding(brush, RadialGradientBrush.OpacityProperty, opacityBinding); return(brush); }
private void UserControl_Loaded(object sender, RoutedEventArgs e) { var arrow = new Arrow(); arrow.DataContext = DataContext; arrow.IsHitTestVisible = false; var size = DesiredSize; arrow.X1 = size.Width / 2; arrow.Y1 = size.Height / 2; { var xBinding = new MultiBinding(); xBinding.Bindings.Add(new Binding("Exit.Position.X")); xBinding.Bindings.Add(new Binding("Position.X")); xBinding.Converter = new RelativePositionConverter(size.Width / 2); arrow.SetBinding(Arrow.X2Property, xBinding); } { var yBinding = new MultiBinding(); yBinding.Bindings.Add(new Binding("Exit.Position.Y")); yBinding.Bindings.Add(new Binding("Position.Y")); yBinding.Converter = new RelativePositionConverter(size.Height / 2); arrow.SetBinding(Arrow.Y2Property, yBinding); } { var visBinding = new MultiBinding(); visBinding.Bindings.Add(new Binding("Exit")); visBinding.Bindings.Add(new Binding("IsVisible") { Source = this, }); visBinding.Converter = new VisibilityConverter(); arrow.SetBinding(VisibilityProperty, visBinding); } contentPresenterAdorner.Content = arrow; var adornerLayer = AdornerLayer.GetAdornerLayer(this); adornerLayer.Add(contentPresenterAdorner); adornerLayer.Add(doorExitArrowAdorner); }
private static void _controlChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { BindingOperations.ClearBinding(d, VisibilityProperty); MultiBinding b = new MultiBinding() { Converter = new IntegersToVisibilityConverter() }; b.Bindings.Add(new Binding("Page") { Source = e.NewValue }); b.Bindings.Add(new Binding("PageIndex") { Source = ServiceLocator.Current.GetInstance <MainViewModel>() }); BindingOperations.SetBinding(d, VisibilityProperty, b); //throw new NotImplementedException(); }
/// <summary> /// Initializes a new instance of the <see cref="BindingSlave"/> class. /// </summary> /// <param name="multiBinding">The multi binding.</param> public BindingSlave( MultiBinding multiBinding ) { _multiBinding = multiBinding; }