void Loaded(object sender, RoutedEventArgs e) { _targetElement.Loaded -= Loaded; foreach (MultiBinding binding in Bindings) { FieldInfo field = _targetElement.GetType().GetField(binding.TargetProperty + "Property", BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy); if (field == null) { continue; } System.Windows.Data.MultiBinding newBinding = new System.Windows.Data.MultiBinding { Converter = binding.Converter, ConverterParameter = binding.ConverterParameter }; foreach (BindingBase bindingBase in binding.Bindings) { newBinding.Bindings.Add(bindingBase); } DependencyProperty dp = (DependencyProperty)field.GetValue(_targetElement); BindingOperations.SetBinding(_targetElement, dp, newBinding); } }
public StyleSelectionMenuItemList() { ItemsSource = ItemsSource = AvailableStyles.Instance; var checkableMenuItemStyle = new Style { TargetType = typeof(MenuItem) }; var headerBinding = new Binding(); var headerSetter = new Setter(HeaderProperty, headerBinding); checkableMenuItemStyle.Setters.Add(headerSetter); var isCheckableSetter = new Setter(IsCheckableProperty, true); checkableMenuItemStyle.Setters.Add(isCheckableSetter); ICommand command = new RelayCommand(SelectStyle); var commandSetter = new Setter(CommandProperty, command); checkableMenuItemStyle.Setters.Add(commandSetter); var commandParamBinding = new Binding(); var commandParamSetter = new Setter(CommandParameterProperty, commandParamBinding); checkableMenuItemStyle.Setters.Add(commandParamSetter); var isCheckedMultiBinding = new MultiBinding { Converter = new MultiValueStringsMatchConverter(), Mode = BindingMode.OneWay }; isCheckedMultiBinding.Bindings.Add(new Binding { Mode = BindingMode.OneWay }); isCheckedMultiBinding.Bindings.Add(new Binding("SelectedStyle") { Source = AvailableStyles.Instance, Mode = BindingMode.OneWay }); var isCheckedSetter = new Setter(IsCheckedProperty, isCheckedMultiBinding); checkableMenuItemStyle.Setters.Add(isCheckedSetter); Resources.Add(typeof(MenuItem), checkableMenuItemStyle); }
private void SetMultiBinding() { //准备基础Binding var b1 = new Binding("Text") { Source = TextBox1 }; var b2 = new Binding("Text") { Source = TextBox2 }; var b3 = new Binding("Text") { Source = TextBox3 }; var b4 = new Binding("Text") { Source = TextBox4 }; //准备MultiBinding var mb = new System.Windows.Data.MultiBinding { Mode = BindingMode.OneWay }; mb.Bindings.Add(b1); //MultiBinding对Add子Binding的顺序是敏感的 mb.Bindings.Add(b2); mb.Bindings.Add(b3); mb.Bindings.Add(b4); mb.Converter = new LogonMultiBindingConverter(); //将Button与MultiBinding对象关联 Button.SetBinding(IsEnabledProperty, mb); }
public PieChartLegendItem(PieChartItem pieChartItem, PieChart chart) { ResourceDictionary dict = (ResourceDictionary)Application.LoadComponent(new Uri("/DynamicDataDisplay.Markers;component/PieChart files/PieChartResources.xaml", UriKind.Relative)); //NewLegend.SetChart(this, pieChartItem); DataContext = pieChartItem.DataContext; Style selfStyle = (Style)dict[GetType()]; Style = selfStyle; Binding fillBinding = new Binding { Path = new PropertyPath("Background"), Source = pieChartItem }; SetBinding(BackgroundProperty, fillBinding); if (chart.DependentValueBinding != null) { SetBinding(NewLegend.DescriptionProperty, chart.DependentValueBinding); } bool setTooltipBinding = !String.IsNullOrEmpty(chart.IndependentValuePath) && !String.IsNullOrEmpty(chart.DependentValuePath); if (setTooltipBinding) { MultiBinding tooltipBinding = new MultiBinding { Converter = new PieLegendItemTooltipConverter() }; tooltipBinding.Bindings.Add(chart.DependentValueBinding); tooltipBinding.Bindings.Add(chart.IndependentValueBinding); SetBinding(ToolTipService.ToolTipProperty, tooltipBinding); } }
public MultiValidatorPanel(UIElement content, UIElement[] elements, DependencyProperty property, IValidate validation, ValidationAggregationType type) { Content = content; MultiBinding multiBinding = new MultiBinding(); switch (type) { case ValidationAggregationType.And: multiBinding.Converter = new AndValidationConverter(validation); break; case ValidationAggregationType.Or: multiBinding.Converter = new OrValidationConverter(validation); break; } for (var i = 0; i < elements.Length; ++i) { Binding b = new Binding() { Source = elements[i], Path = new PropertyPath(property.Name), Mode = BindingMode.OneWay }; multiBinding.Bindings.Add(b); } this.SetBinding(ValidProperty, multiBinding); }
private void SetMultiBinding() { //准备基础binding Binding b1 = new Binding("Text") { Source = tb1 }; Binding b2 = new Binding("Text") { Source = tb2 }; Binding b3 = new Binding("Text") { Source = tb3 }; Binding b4 = new Binding("Text") { Source = tb4 }; //准备multiBinding System.Windows.Data.MultiBinding mb = new System.Windows.Data.MultiBinding(); mb.Bindings.Add(b1); mb.Bindings.Add(b2); mb.Bindings.Add(b3); mb.Bindings.Add(b4); mb.Converter = new LogonMultiBindingConverter(); //将button与multiBinding对象关联 btn1.SetBinding(Button.IsEnabledProperty, mb); }
public BindingBase ProvideBinding(IResourceContext context) { if (Resources == null || Resources.Count == 0) { return(new LiteralValue(StringFormat).ProvideBinding(context)); } if (Resources.Count == 1) { var resource = Resources[0]; var binding = resource.ProvideBinding(context); if (StringFormat != null) { binding.StringFormat = StringFormat; } return(binding); } var multiBinding = new System.Windows.Data.MultiBinding { StringFormat = StringFormat }; foreach (var binding in Resources.Select(resource => resource.ProvideBinding(context))) { multiBinding.Bindings.Add(binding); } return(multiBinding); }
public ReadOnlyAllAnswersControl() { InitializeComponent(); if (DesignerProperties.GetIsInDesignMode(this)) { this.HandleDesignTimeView(); } //this.mPartialsForQuestion.SetBinding(UserControl.VisibilityProperty, QuestionControl.PartialsIsEmptyToVisibilityBinding); // Set up the No Questions Yet message FrameworkElement noQuestionsMessage = this.mNoQuestionsMessage; MultiBinding noQuestionsBinding = new MultiBinding(); noQuestionsBinding.Bindings.Add(new Binding() { Path = new PropertyPath("OpenQuestions.IsEmpty") }); noQuestionsBinding.Bindings.Add(new Binding() { Path = new PropertyPath("ClosedQuestions.IsEmpty") }); noQuestionsBinding.Converter = new NoQuestionsMessageVisibilityConverter(); noQuestionsMessage.SetBinding(UIElement.VisibilityProperty, noQuestionsBinding); // Set up the allQuestionsClosedMessage MultiBinding allQuestionsClosedBinding = new MultiBinding(); allQuestionsClosedBinding.Bindings.Add(new Binding() { Path = new PropertyPath("OpenQuestions.IsEmpty") }); allQuestionsClosedBinding.Bindings.Add(new Binding() { Path = new PropertyPath("ClosedQuestions.IsEmpty") }); allQuestionsClosedBinding.Converter = new AllQuestionsClosedMessageVisibilityConverter(); this.mAllQuestionsClosedMessage.SetBinding(UIElement.VisibilityProperty, allQuestionsClosedBinding); }
public QuestionListControl() { InitializeComponent(); if (DesignerProperties.GetIsInDesignMode(this)) { this.HandleDesignTimeView(); } // Set up the divider FrameworkElement divider = this.mQuestionsDivider; MultiBinding dividerBinding = new MultiBinding(); dividerBinding.Bindings.Add(new Binding() { Path = new PropertyPath("OpenQuestions.IsEmpty") }); dividerBinding.Bindings.Add(new Binding() { Path = new PropertyPath("ClosedQuestions.IsEmpty") }); dividerBinding.Converter = new QuestionsDividerVisibilityConverter(); divider.SetBinding(UIElement.VisibilityProperty, dividerBinding); // Set up the No Questions Yet message FrameworkElement noQuestionsMessage = this.mNoQuestionsMessage; MultiBinding noQuestionsBinding = new MultiBinding(); noQuestionsBinding.Bindings.Add(new Binding() { Path = new PropertyPath("OpenQuestions.IsEmpty") }); noQuestionsBinding.Bindings.Add(new Binding() { Path = new PropertyPath("ClosedQuestions.IsEmpty") }); noQuestionsBinding.Converter = new NoQuestionsMessageVisibilityConverter(); noQuestionsMessage.SetBinding(UIElement.VisibilityProperty, noQuestionsBinding); }
public TestUserControl() { InitializeComponent(); return; KeepPreviewColor = false; ColorsBox.ItemsSource = typeof(Colors).GetProperties(); #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 }
public override object ProvideValue(IServiceProvider serviceProvider) { if (this.Key == null && this.KeyBinding == null) throw new ArgumentException("Either Key or KeyBinding must be set"); if (this.Key != null && this.KeyBinding != null) throw new ArgumentException("Either Key or KeyBinding must be set, but not both"); if (this.ValueBinding != null && this.ValueBindings != null) throw new ArgumentException("ValueBinding and ValueBindings may not be set at the same time"); // Most of these conditions are redundent, according to the assertions above. However I'll still state them, // for clarity. // A static key, and no values if (this.Key != null && this.KeyBinding == null && this.ValueBinding == null && this.ValueBindings == null) { // Just returning a string! return Localizer.Translate(this.Key); } // A static key, and a single value if (this.Key != null && this.KeyBinding == null && this.ValueBinding != null && this.ValueBindings == null) { var converter = new StaticKeySingleValueConverter() { Key = this.Key, Converter = this.ValueBinding.Converter }; this.ValueBinding.Converter = converter; return this.ValueBinding.ProvideValue(serviceProvider); } // A static key, and multiple values if (this.Key != null && this.KeyBinding == null && this.ValueBinding == null && this.ValueBindings != null) { var converter = new StaticKeyMultipleValuesConverter() { Key = this.Key, Converter = this.ValueBindings.Converter }; this.ValueBindings.Converter = converter; return this.ValueBindings.ProvideValue(serviceProvider); } // A bound key, no values if (this.Key == null && this.KeyBinding != null && this.ValueBinding == null && this.ValueBindings == null) { var converter = new BoundKeyNoValuesConverter() { Converter = this.KeyBinding.Converter }; this.KeyBinding.Converter = converter; return this.KeyBinding.ProvideValue(serviceProvider); } // A bound key, and one value if (this.Key == null && this.KeyBinding != null && this.ValueBinding != null && this.ValueBindings == null) { var converter = new BoundKeyWithValuesConverter(); var multiBinding = new MultiBinding() { Converter = converter }; multiBinding.Bindings.Add(this.KeyBinding); multiBinding.Bindings.Add(this.ValueBinding); return multiBinding.ProvideValue(serviceProvider); } // A bound key, and multiple values if (this.Key == null && this.KeyBinding != null && this.ValueBinding == null && this.ValueBindings != null) { var converter = new BoundKeyWithValuesConverter() { ValuesConverter = this.ValueBindings.Converter }; this.ValueBindings.Bindings.Insert(0, this.KeyBinding); this.ValueBindings.Converter = converter; return this.ValueBindings.ProvideValue(serviceProvider); } throw new Exception("Should never get here"); }
public override object ProvideValue(IServiceProvider rpServiceProvider) { var rResult = new MultiBinding() { Converter = CoreConverter.Instance }; rResult.Bindings.Add(new Binding() { RelativeSource = new RelativeSource(RelativeSourceMode.FindAncestor, typeof(ListView), 1) }); rResult.Bindings.Add(new Binding()); return rResult.ProvideValue(rpServiceProvider); }
public override object ProvideValue(IServiceProvider rpServiceProvider) { var rResult = new MultiBinding() { Mode = BindingMode.OneWay, Converter = CoreConverter.Instance }; rResult.Bindings.Add(new Binding("ModifierKeys.Value") { Source = Preference.Instance.Other.PanicKey }); rResult.Bindings.Add(new Binding("Key.Value") { Source = Preference.Instance.Other.PanicKey }); return rResult.ProvideValue(rpServiceProvider); }
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); }
public override object ProvideValue(IServiceProvider rpServiceProvider) { var rResult = new MultiBinding() { Mode = BindingMode.OneWay, Converter = Converter.Instance, ConverterParameter = r_Type, StringFormat = StringFormat }; rResult.Bindings.Add(new Binding(r_IDPath)); rResult.Bindings.Add(new Binding(r_OriginalTextPath)); rResult.Bindings.Add(new Binding(nameof(StringResources.Instance.Extra)) { Source = StringResources.Instance }); return rResult.ProvideValue(rpServiceProvider); }
/// <summary> /// Initializes a new instance of the <see cref="MultiBindingExpression"/> class and applies it to the given target. /// </summary> /// <param name="target">The target.</param> /// <param name="multiBinding">The parent <see cref="MultiBinding"/></param> public MultiBindingExpression(DependencyObject target, MultiBinding multiBinding) { if (target == null) throw new ArgumentNullException("target"); if (multiBinding == null) throw new ArgumentNullException("multiBinding"); Target = target; MultiBinding = multiBinding; ApplyToTarget(); }
//------------------------------------------------------ // // Constructors // //------------------------------------------------------ /// <summary> Constructor </summary> private MultiBindingExpression(MultiBinding binding, BindingExpressionBase owner) : base(binding, owner) { int count = binding.Bindings.Count; // reduce repeated allocations _tempValues = new object[count]; _tempTypes = new Type[count]; }
private void SetMultiBinding() { Binding b1 = new Binding("Text") { Source = this.txtBox1 }; Binding b2 = new Binding("Text") { Source = this.txtBox2 }; Binding b3 = new Binding("Text") { Source = this.txtBox3 }; Binding b4 = new Binding("Text") { Source = this.txtBox4 }; MultiBinding mb = new MultiBinding { Mode = BindingMode.OneWay, Bindings = { b1, b2, b3, b4 } }; mb.Converter = new LogonMultiBindingConverter(); this.btn1.SetBinding(Button.IsEnabledProperty, mb); }
private static MultiBinding GetStatBinding(BattleEntity source, BattleEntityStatCalculationData calculationData) { var statBinding = new MultiBinding { Converter = new BattleEntityStatCalculationConverter() }; statBinding.Bindings.Add(new Binding { Source = calculationData.CalculationFunction }); foreach (var bindingPath in calculationData.BindingPaths) { statBinding.Bindings.Add(new Binding(bindingPath) { Source = source }); } return statBinding; }
public BattleActionBar() { InitializeComponent(); //set up the filled bindings var percentFilledBinding = new MultiBinding { Converter = new BattleActionBarPercentFilledConverter() }; percentFilledBinding.Bindings.Add(new Binding("Value") { Source = this }); percentFilledBinding.Bindings.Add(new Binding("MaximumValue") { Source = this }); percentFilledBinding.Bindings.Add(new Binding("ActualHeight") { Source = this }); BindingOperations.SetBinding(this, PercentFilledProperty, percentFilledBinding); }
public override object ProvideValue(IServiceProvider rpServiceProvider) { if (!StringResources.Instance.IsLoaded) return Path; var rResult = new MultiBinding() { Converter = r_Converter, ConverterParameter = Prefix, StringFormat = StringFormat, Mode = Mode, TargetNullValue = TargetNullValue }; rResult.Bindings.Add(new Binding(Path)); rResult.Bindings.Add(new Binding(nameof(StringResources.Instance.Main)) { Source = StringResources.Instance }); return rResult.ProvideValue(rpServiceProvider); }
public override BindingBase ProvideBinding(IResourceContext context) { var multiBinding = new System.Windows.Data.MultiBinding(); multiBinding.Converter = GetMultiValueConverter(context); foreach (var resource in Resources) { multiBinding.Bindings.Add(resource.ProvideBinding(context)); } multiBinding.Mode = OneTimeBinding ? BindingMode.OneTime : BindingMode.OneWay; return(multiBinding); }
override public bool CanWorkWithBinding(System.Windows.Data.BindingBase binding) { if (binding != null && binding is System.Windows.Data.MultiBinding) { System.Windows.Data.MultiBinding bind = binding as System.Windows.Data.MultiBinding; if (bind.Converter is ScriptConverter == false) { return(false); } return(true); } return(false); }
public override object ProvideValue(IServiceProvider rpServiceProvider) { var rResult = new MultiBinding() { Mode = BindingMode.OneWay, Converter = CoreConverter.Instance }; rResult.Bindings.Add(new Binding() { Path = new PropertyPath(MetroWindow.ScreenOrientationProperty), RelativeSource = new RelativeSource(RelativeSourceMode.FindAncestor, typeof(MetroWindow), 1) }); rResult.Bindings.Add(new Binding("Layout.LandscapeDock") { Source = Preference.Current }); rResult.Bindings.Add(new Binding("Layout.PortraitDock") { Source = Preference.Current }); rResult.Bindings.Add(new Binding() { RelativeSource = RelativeSource.Self }); if (Converter != null) rResult.ConverterParameter = Tuple.Create(Converter, ConverterParameter); return rResult.ProvideValue(rpServiceProvider); }
public BindingBase ProvideBinding(IResourceContext context) { var multiBinding = new System.Windows.Data.MultiBinding { Converter = new BooleanMultiConverter(Ast, Resource.GetValueConverter(context, Converter)) }; foreach (var binding in ValueProviders.Select(provider => provider.ProvideBinding(context))) { multiBinding.Bindings.Add(binding); } return(multiBinding); }
partial void SetTransactionInfo(TransactionInfo transactionInfo) { //This instance of TransactionInfo acts as a "shared model" between this view and the order details view. //The scenario says that these 2 views are decoupled, so they don't share the view model, they are only tied //with this TransactionInfo this.orderDetailsViewModel.TransactionInfo = transactionInfo; //Bind the CompositeOrderView header to a string representation of the TransactionInfo shared instance (we expect the details view model to modify it from user interaction). MultiBinding binding = new MultiBinding(); binding.Bindings.Add(new Binding("TransactionType") { Source = transactionInfo }); binding.Bindings.Add(new Binding("TickerSymbol") { Source = transactionInfo }); binding.Converter = new OrderHeaderConverter(); BindingOperations.SetBinding(this, HeaderInfoProperty, binding); }
public override object ProvideValue(IServiceProvider serviceProvider) { var resourceKeyBinding = new Binding() { BindsDirectlyToSource = BindsDirectlyToSource, Mode = BindingMode.OneWay, Path = Path, XPath = XPath, }; //Binding throws an InvalidOperationException if we try setting all three // of the following properties simultaneously: thus make sure we only set one if (ElementName != null) { resourceKeyBinding.ElementName = ElementName; } else if (RelativeSource != null) { resourceKeyBinding.RelativeSource = RelativeSource; } else if (Source != null) { resourceKeyBinding.Source = Source; } var targetElementBinding = new Binding(); targetElementBinding.RelativeSource = new RelativeSource() { Mode = RelativeSourceMode.Self }; var multiBinding = new MultiBinding(); multiBinding.Bindings.Add(targetElementBinding); multiBinding.Bindings.Add(resourceKeyBinding); // If we set the Converter on resourceKeyBinding then, for some reason, // MultiBinding wants it to produce a value matching the Target Type of the MultiBinding // When it doesn't, it throws a wobbly and passes DependencyProperty.UnsetValue through // to our MultiBinding ValueConverter. To circumvent this, we do the value conversion ourselves. // See http://social.msdn.microsoft.com/forums/en-US/wpf/thread/af4a19b4-6617-4a25-9a61-ee47f4b67e3b multiBinding.Converter = new ResourceKeyToResourceConverter() { ResourceKeyConverter = Converter, ConverterParameter = ConverterParameter, StringFormat = StringFormat, }; return multiBinding.ProvideValue(serviceProvider); }
public override object ProvideValue(IServiceProvider serviceProvider) { if (MultiBinding != null) { if (Bindings.Any()) throw new ArgumentException($"{nameof(Bindings)} should be an empty"); if (Converter != null) throw new ArgumentException($"{nameof(Converter)} should be a null"); } else { if (!Bindings.Any()) throw new ArgumentNullException(nameof(Bindings)); if (Converter == null) throw new ArgumentNullException(nameof(Converter)); } var target = (IProvideValueTarget)serviceProvider.GetService(typeof(IProvideValueTarget)); if (target.TargetObject.GetType().FullName == "System.Windows.SharedDp") return this; if (MultiBinding != null) { Converter = MultiBinding.Converter; ConverterParameter = MultiBinding.ConverterParameter; ConverterCulture = MultiBinding.ConverterCulture; foreach (var bindingBase in MultiBinding.Bindings) Bindings.Add(bindingBase); } if (target.TargetObject is NestedBindingCollection) { var binding = new Binding { Source = this }; return binding; } var multiBinding = new MultiBinding { Mode = BindingMode.OneWay }; var tree = GetNestedBindingsTree(this, multiBinding); var converter = new NestedBindingConverter(tree); multiBinding.Converter = converter; return multiBinding.ProvideValue(serviceProvider); }
void ErrorSummary_Loaded(object sender, RoutedEventArgs e) { if (DesignerProperties.GetIsInDesignMode(this)) return; var parent = (FrameworkElement)this.Parent; parent.AddHandler(Validation.ErrorEvent, new EventHandler<ValidationErrorEventArgs>(ErrorHandler)); var multi = new MultiBinding { Converter = DoubleListConverter.Instance }; multi.Bindings.Add(new Binding("BindingExceptions") { Source = this }); multi.Bindings.Add(new Binding("DataContext.Error") { Source = parent }); lb.SetBinding(ItemsControl.ItemsSourceProperty, multi); this.SetBinding(HasErrorsProperty, new Binding("ItemsSource") { Source = lb, Converter = Converters.ErrorListToBool }); }
public MatchUsingRadio() { InitializeComponent(); MultiBinding multiBinding = new MultiBinding { Converter = new MatchUsingConverter(), Mode = BindingMode.TwoWay }; multiBinding.Bindings.Add(new Binding("IsChecked") { ElementName = "FileNameRadio" }); multiBinding.Bindings.Add(new Binding("IsChecked") { ElementName = "TitleRadio" }); multiBinding.Bindings.Add(new Binding("IsChecked") { ElementName = "ClassRadio" }); SetBinding(MatchUsingProperty, multiBinding); }
private 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; }
public override void SetBinding(object parameter) { //генерим биндинги var bindings = _canvasPaths.Select(t => new Binding(Path) { Path = new PropertyPath(t), ElementName = ElementName, }).ToList(); var multibinding = new MultiBinding { Converter = _converter, ConverterParameter = parameter, }; foreach (var binding in bindings) multibinding.Bindings.Add(binding); Element.SetBinding(Property, multibinding); }
public PartialsForQuestionControl() { InitializeComponent(); // QuestionViewModel is the DataContext here // Set it's own visibility based on whether there's stuff to show this.SetBinding(UserControl.VisibilityProperty, new Binding() { Path = new PropertyPath("PartialAnswers.IsEmpty"), Converter = FalseToVisibleConverter }); MultiBinding editLinkBinding = new MultiBinding(); editLinkBinding.Bindings.Add(new Binding() { Path = new PropertyPath("DataContext.IsContributorOnlyMode"), RelativeSource = new RelativeSource(RelativeSourceMode.FindAncestor, typeof(TriviaClient), 1) }); editLinkBinding.Bindings.Add(new Binding() { Path = new PropertyPath("AllowEditingOfPartials"), RelativeSource = new RelativeSource(RelativeSourceMode.FindAncestor, typeof(PartialsForQuestionControl), 1) }); editLinkBinding.Converter = new EditLinkBindingConverter(); this.mEditPartialsLink.SetBinding(TextBlock.VisibilityProperty, editLinkBinding); }
public BattleEntityInBattle(BattleEntity battleEntity) { BattleEntity = battleEntity; var normalizedStartingAction = 100.0 * battleEntity.BaseStats.Speed / Constants.STATS_MAX_PRIMARY_STAT; ActionCounter = Math.Max(0, RandomUtility.RandomGaussian(normalizedStartingAction, 25)); //wire up the is alive property var isAliveBinding = new Binding("BattleEntity.CurrentHealth") { Source = this, Converter = new BattleEntityInBattleIsAliveConverter() }; BindingOperations.SetBinding(this, IsAliveProperty, isAliveBinding); //wire up the action status property var actionStatusBinding = new MultiBinding { Converter = new BattlePartyMemberActionStatusConverter() }; actionStatusBinding.Bindings.Add(new Binding("ActionCounter") { Source = this }); actionStatusBinding.Bindings.Add(new Binding("HasQueuedAbility") { Source = this }); BindingOperations.SetBinding(this, ActionStatusProperty, actionStatusBinding); }
public override object ProvideValue(IServiceProvider rpServiceProvider) { var rSource = Preference.Instance.UI.HeavyDamageLine; var rResult = new MultiBinding() { Mode = BindingMode.OneWay, Converter = CoreConverter.Instance, Bindings = { new Binding(nameof(rSource.Type.Value)) { Source = rSource.Type } }, }; if (!r_State.HasValue) rResult.Bindings.Add(new Binding("State")); else rResult.ConverterParameter = r_State.Value; return rResult.ProvideValue(rpServiceProvider); }
private static void AlignmentChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { FrameworkElement element = d as FrameworkElement; if (element == null) { return; } element.ClearValue(FrameworkElement.MarginProperty); MultiBinding multiBinding = new MultiBinding { Converter = new AlignmentConverter((TextAlign) e.NewValue, GetLineAlignment(d)) }; multiBinding.Bindings.Add(new Binding("ActualWidth") { Source = element }); multiBinding.Bindings.Add(new Binding("ActualHeight") { Source = element }); element.SetBinding(FrameworkElement.MarginProperty, multiBinding); }
private 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; }
public override void Initialize(object element, PropertyWrapper property, System.Windows.Data.BindingBase binding) { base.Initialize(element, property, binding); DependencyObject depObj; DependencyProperty depProp; if (property.GetWpfObjects(out depObj, out depProp)) { if (depObj.GetValue(depProp) is String) { expressionEdit.Text = (string)depObj.GetValue(depProp); } } System.Windows.Data.MultiBinding bind = binding as System.Windows.Data.MultiBinding; if (bind != null) { expressionEdit.Text = (bind.Converter as ScriptConverter).Expression; channels.Clear(); foreach (System.Windows.Data.BindingBase bindingBase in bind.Bindings) { if (bindingBase is System.Windows.Data.Binding) { System.Windows.Data.Binding b = bindingBase as System.Windows.Data.Binding; if (b.Source is ChannelDataProvider) { ChannelDataProvider src = (ChannelDataProvider)b.Source; channels.Add(src.Channel); } } } FillChannelsGrid(); } }
// Token: 0x06001C3B RID: 7227 RVA: 0x00084BD8 File Offset: 0x00082DD8 private BindingExpressionBase AttachBindingExpression(int i, bool replaceExisting) { DependencyObject targetElement = base.TargetElement; if (targetElement == null) { return(null); } BindingBase bindingBase = this.ParentMultiBinding.Bindings[i]; MultiBinding.CheckTrigger(bindingBase); BindingExpressionBase bindingExpressionBase = bindingBase.CreateBindingExpression(targetElement, base.TargetProperty, this); if (replaceExisting) { this.MutableBindingExpressions[i] = bindingExpressionBase; } else { this.MutableBindingExpressions.Add(bindingExpressionBase); } bindingExpressionBase.Attach(targetElement, base.TargetProperty); return(bindingExpressionBase); }
// Token: 0x06001C22 RID: 7202 RVA: 0x00083F80 File Offset: 0x00082180 internal static MultiBindingExpression CreateBindingExpression(DependencyObject d, DependencyProperty dp, MultiBinding binding, BindingExpressionBase owner) { FrameworkPropertyMetadata frameworkPropertyMetadata = dp.GetMetadata(d.DependencyObjectType) as FrameworkPropertyMetadata; if ((frameworkPropertyMetadata != null && !frameworkPropertyMetadata.IsDataBindingAllowed) || dp.ReadOnly) { throw new ArgumentException(SR.Get("PropertyNotBindable", new object[] { dp.Name }), "dp"); } MultiBindingExpression multiBindingExpression = new MultiBindingExpression(binding, owner); multiBindingExpression.ResolvePropertyDefaultSettings(binding.Mode, binding.UpdateSourceTrigger, frameworkPropertyMetadata); return(multiBindingExpression); }
public override object ProvideValue(IServiceProvider serviceProvider) { try { bool getExpression; if (serviceProvider == null) { getExpression = false; } else { var targetProvider = serviceProvider.GetService(typeof(IProvideValueTarget)) as IProvideValueTarget; if (targetProvider != null && (targetProvider.TargetObject is Setter)) { getExpression = false; } else if (targetProvider == null || !(targetProvider.TargetProperty is PropertyInfo)) { getExpression = true; } else { Type propType = (targetProvider.TargetProperty as PropertyInfo).PropertyType; if (propType == typeof(MultiBinding)) { return(this); } getExpression = !propType.IsAssignableFrom(typeof(System.Windows.Data.MultiBinding)); } } var holder = new System.Windows.Data.MultiBinding() { Mode = Mode, UpdateSourceTrigger = UpdateSourceTrigger }; if (FallbackValue != null) { holder.FallbackValue = FallbackValue; } if (TargetNullValue != null) { holder.TargetNullValue = TargetNullValue; } if (ExternalConverter == null) { holder.ConverterParameter = ConverterParameter; string[] parameterOrder; holder.Converter = new QuickMultiConverter() { Converter = Converter, DynamicContext = DynamicContext, P0Type = P0Type, P1Type = P1Type, P2Type = P2Type, P3Type = P3Type, P4Type = P4Type, P5Type = P5Type, P6Type = P6Type, P7Type = P7Type, P8Type = P8Type, P9Type = P9Type, V0 = V0, V1 = V1, V2 = V2, V3 = V3, V4 = V4, V5 = V5, V6 = V6, V7 = V7, V8 = V8, V9 = V9, ConvertBack0 = ConvertBack0, ConvertBack1 = ConvertBack1, ConvertBack2 = ConvertBack2, ConvertBack3 = ConvertBack3, ConvertBack4 = ConvertBack4, ConvertBack5 = ConvertBack5, ConvertBack6 = ConvertBack6, ConvertBack7 = ConvertBack7, ConvertBack8 = ConvertBack8, ConvertBack9 = ConvertBack9 }.Get(out parameterOrder); foreach (string name in parameterOrder) { holder.Bindings.Add(typeof(MultiBinding).GetProperty(name).GetValue(this, null) as BindingBase); } if (!_modeSet) { bool exists = false; for (int i = 0; i <= 9; ++i) { exists |= !String.IsNullOrWhiteSpace(typeof(MultiBinding).GetProperty("ConvertBack" + i).GetValue(this, null) as string); } holder.Mode = exists ? BindingMode.TwoWay : BindingMode.OneWay; } } else { if (ExternalConverterParameterMode == ConverterParameterMode.Parameter) { holder.ConverterParameter = ConverterParameter; } else { holder.ConverterParameter = new object[] { V0, V1, V2, V3, V4, V5, V6, V7, V8, V9 } }; holder.Converter = ExternalConverter; for (int i = 0; i <= 9; ++i) { var binding = typeof(MultiBinding).GetProperty("P" + i).GetValue(this, null) as BindingBase; if (binding != null) { holder.Bindings.Add(binding); } } } return(getExpression ? holder.ProvideValue(serviceProvider) : holder); } catch (Exception e) { EquationTokenizer.ThrowQuickConverterEvent(new MarkupExtensionExceptionEventArgs(Converter, this, e)); throw; } }