multibinding 相关问题

MultiBinding是Microsoft .NET WPF中的XAML标记,使您可以将多个数据源组合到可用于数据绑定的单个数据集合中。

使用 InvokeCommandAction 将额外参数传递给命令

有没有办法通过 Microsoft.Xaml.Behaviors.Wpf 中的 InvokeCommandAction 将额外参数(以及默认参数)传递给命令? 就像下面这样: 有没有办法通过 InvokeCommandAction 中的 Microsoft.Xaml.Behaviors.Wpf 将额外参数(与默认参数一起)传递给命令? 像下面这样: <behaviors:Interaction.Triggers> <behaviors:EventTrigger EventName="MouseDown"> <behaviors:InvokeCommandAction Command="{Binding Command, Mode=OneWay}" PassEventArgsToCommand="True" /> </behaviors:EventTrigger> </behaviors:Interaction.Triggers> 这里传递的参数是MouseButtonEventArgs: <behaviors:Interaction.Triggers> <behaviors:EventTrigger EventName="MouseDown"> <behaviors:InvokeCommandAction Command="{Binding Command, Mode=OneWay}" PassEventArgsToCommand="True"> <behaviors:InvokeCommandAction.CommandParameter> <MultiBinding Converter="{StaticResource ResourceKey=CommandConverter}"> <Binding ElementName="OtherElement" Mode="OneWay" /> </MultiBinding> </behaviors:InvokeCommandAction.CommandParameter> </behaviors:InvokeCommandAction> </behaviors:EventTrigger> </behaviors:Interaction.Triggers> 这里我想把 OtherElement 和 MouseButtonEventArgs 一起传递。有没有办法指定 MouseButtonEventArgs 参数? InvokeCommandAction 仅支持一个CommandParameter,即事件参数或绑定命令参数。如果您尝试同时执行这两项操作,命令参数将优先。由于 XAML 行为是开源的,您可以在 Github 上该类的 Invoke 方法中亲自查看它。 为了同时通过这两项,您必须编写自己的操作。如果您可以简单地创建 InvokeCommandAction 的派生类型并覆盖 Invoke,这将是一项简单的任务,但不幸的是它是 sealed。这意味着,您必须复制 InvokeCommandAction 的代码并进行调整。 首先,创建一个封装事件参数和命令参数的小类。 public class CompositeCommandParameter { public CompositeCommandParameter(EventArgs eventArgs, object parameter) { EventArgs = eventArgs; Parameter = parameter; } public EventArgs EventArgs { get; } public object Parameter { get; } } 接下来,从 GitHub 复制代码。本质上,您必须用自定义类型替换对 InvokeCommandAction 类型的显式引用,这里是 AdvancedInvokeCommandAction,当然还要调整 Invoke 方法,以便它创建一个 CompositeCommandParameter 实例并用它调用命令。 public sealed class AdvancedInvokeCommandAction : TriggerAction<DependencyObject> { private string commandName; public static readonly DependencyProperty CommandProperty = DependencyProperty.Register("Command", typeof(ICommand), typeof(AdvancedInvokeCommandAction), null); public static readonly DependencyProperty CommandParameterProperty = DependencyProperty.Register("CommandParameter", typeof(object), typeof(AdvancedInvokeCommandAction), null); public static readonly DependencyProperty EventArgsConverterProperty = DependencyProperty.Register("EventArgsConverter", typeof(IValueConverter), typeof(AdvancedInvokeCommandAction), new PropertyMetadata(null)); public static readonly DependencyProperty EventArgsConverterParameterProperty = DependencyProperty.Register("EventArgsConverterParameter", typeof(object), typeof(AdvancedInvokeCommandAction), new PropertyMetadata(null)); public static readonly DependencyProperty EventArgsParameterPathProperty = DependencyProperty.Register("EventArgsParameterPath", typeof(string), typeof(AdvancedInvokeCommandAction), new PropertyMetadata(null)); // ...other code. public object CommandParameter { get { return this.GetValue(AdvancedInvokeCommandAction.CommandParameterProperty); } set { this.SetValue(AdvancedInvokeCommandAction.CommandParameterProperty, value); } } // ...other code. protected override void Invoke(object parameter) { if (this.AssociatedObject != null) { ICommand command = this.ResolveCommand(); if (command != null) { object eventArgs = null; object commandParameter = this.CommandParameter; //if no CommandParameter has been provided, let's check the EventArgsParameterPath if (!string.IsNullOrWhiteSpace(this.EventArgsParameterPath)) { eventArgs = GetEventArgsPropertyPathValue(parameter); } //next let's see if an event args converter has been supplied if (eventArgs == null && this.EventArgsConverter != null) { eventArgs = this.EventArgsConverter.Convert(parameter, typeof(object), EventArgsConverterParameter, CultureInfo.CurrentCulture); } //last resort, let see if they want to force the event args to be passed as a parameter if (eventArgs == null && this.PassEventArgsToCommand) { eventArgs = parameter; } if (command.CanExecute(commandParameter)) { var compositeCommandParameter = new CompositeCommandParameter((EventArgs) eventArgs, commandParameter); command.Execute(compositeCommandParameter); } } } } // ...other code. } 在您的 XAML 代码中,您现在可以同时使用两者。由于您很可能仅将此操作与两个参数一起使用,因此您可以进一步自定义该操作以删除 PassEventArgsToCommand 参数。 <b:Interaction.Triggers> <b:EventTrigger EventName="MouseDown"> <local:AdvancedInvokeCommandAction Command="{Binding Command, Mode=OneWay}" PassEventArgsToCommand="True" CommandParameter="{Binding ElementName=OtherElement}" /> </b:EventTrigger> </b:Interaction.Triggers> 在您的视图模型中,该命令现在将获取类型为 CompositeCommandParameter 的对象。 这是 AdvancedInvokeCommandAction 的完整代码。 public sealed class AdvancedInvokeCommandAction : TriggerAction<DependencyObject> { private string commandName; public static readonly DependencyProperty CommandProperty = DependencyProperty.Register("Command", typeof(ICommand), typeof(AdvancedInvokeCommandAction), null); public static readonly DependencyProperty CommandParameterProperty = DependencyProperty.Register("CommandParameter", typeof(object), typeof(AdvancedInvokeCommandAction), null); public static readonly DependencyProperty EventArgsConverterProperty = DependencyProperty.Register("EventArgsConverter", typeof(IValueConverter), typeof(AdvancedInvokeCommandAction), new PropertyMetadata(null)); public static readonly DependencyProperty EventArgsConverterParameterProperty = DependencyProperty.Register("EventArgsConverterParameter", typeof(object), typeof(AdvancedInvokeCommandAction), new PropertyMetadata(null)); public static readonly DependencyProperty EventArgsParameterPathProperty = DependencyProperty.Register("EventArgsParameterPath", typeof(string), typeof(AdvancedInvokeCommandAction), new PropertyMetadata(null)); /// <summary> /// Gets or sets the name of the command this action should invoke. /// </summary> /// <value>The name of the command this action should invoke.</value> /// <remarks>This property will be superseded by the Command property if both are set.</remarks> public string CommandName { get { this.ReadPreamble(); return this.commandName; } set { if (this.CommandName != value) { this.WritePreamble(); this.commandName = value; this.WritePostscript(); } } } /// <summary> /// Gets or sets the command this action should invoke. This is a dependency property. /// </summary> /// <value>The command to execute.</value> /// <remarks>This property will take precedence over the CommandName property if both are set.</remarks> public ICommand Command { get { return (ICommand)this.GetValue(CommandProperty); } set { this.SetValue(CommandProperty, value); } } /// <summary> /// Gets or sets the command parameter. This is a dependency property. /// </summary> /// <value>The command parameter.</value> /// <remarks>This is the value passed to ICommand.CanExecute and ICommand.Execute.</remarks> public object CommandParameter { get { return this.GetValue(AdvancedInvokeCommandAction.CommandParameterProperty); } set { this.SetValue(AdvancedInvokeCommandAction.CommandParameterProperty, value); } } /// <summary> /// Gets or sets the IValueConverter that is used to convert the EventArgs passed to the Command as a parameter. /// </summary> /// <remarks>If the <see cref="Command"/> or <see cref="EventArgsParameterPath"/> properties are set, this property is ignored.</remarks> public IValueConverter EventArgsConverter { get { return (IValueConverter)GetValue(EventArgsConverterProperty); } set { SetValue(EventArgsConverterProperty, value); } } /// <summary> /// Gets or sets the parameter that is passed to the EventArgsConverter. /// </summary> public object EventArgsConverterParameter { get { return (object)GetValue(EventArgsConverterParameterProperty); } set { SetValue(EventArgsConverterParameterProperty, value); } } /// <summary> /// Gets or sets the parameter path used to extract a value from an <see cref= "EventArgs" /> property to pass to the Command as a parameter. /// </summary> /// <remarks>If the <see cref="Command"/> propert is set, this property is ignored.</remarks> public string EventArgsParameterPath { get { return (string)GetValue(EventArgsParameterPathProperty); } set { SetValue(EventArgsParameterPathProperty, value); } } /// <summary> /// Specifies whether the EventArgs of the event that triggered this action should be passed to the Command as a parameter. /// </summary> /// <remarks>If the <see cref="Command"/>, <see cref="EventArgsParameterPath"/>, or <see cref="EventArgsConverter"/> properties are set, this property is ignored.</remarks> public bool PassEventArgsToCommand { get; set; } /// <summary> /// Invokes the action. /// </summary> /// <param name="parameter">The parameter to the action. If the action does not require a parameter, the parameter may be set to a null reference.</param> protected override void Invoke(object parameter) { if (this.AssociatedObject != null) { ICommand command = this.ResolveCommand(); if (command != null) { object eventArgs = null; object commandParameter = this.CommandParameter; //if no CommandParameter has been provided, let's check the EventArgsParameterPath if (!string.IsNullOrWhiteSpace(this.EventArgsParameterPath)) { eventArgs = GetEventArgsPropertyPathValue(parameter); } //next let's see if an event args converter has been supplied if (eventArgs == null && this.EventArgsConverter != null) { eventArgs = this.EventArgsConverter.Convert(parameter, typeof(object), EventArgsConverterParameter, CultureInfo.CurrentCulture); } //last resort, let see if they want to force the event args to be passed as a parameter if (eventArgs == null && this.PassEventArgsToCommand) { eventArgs = parameter; } if (command.CanExecute(commandParameter)) { var compositeCommandParameter = new CompositeCommandParameter((EventArgs) eventArgs, commandParameter); command.Execute(compositeCommandParameter); } } } } private object GetEventArgsPropertyPathValue(object parameter) { object commandParameter; object propertyValue = parameter; string[] propertyPathParts = EventArgsParameterPath.Split('.'); foreach (string propertyPathPart in propertyPathParts) { PropertyInfo propInfo = propertyValue.GetType().GetProperty(propertyPathPart); propertyValue = propInfo.GetValue(propertyValue, null); } commandParameter = propertyValue; return commandParameter; } private ICommand ResolveCommand() { ICommand command = null; if (this.Command != null) { command = this.Command; } else if (this.AssociatedObject != null) { // todo jekelly 06/09/08: we could potentially cache some or all of this information if needed, updating when AssociatedObject changes Type associatedObjectType = this.AssociatedObject.GetType(); PropertyInfo[] typeProperties = associatedObjectType.GetProperties(BindingFlags.Public | BindingFlags.Instance); foreach (PropertyInfo propertyInfo in typeProperties) { if (typeof(ICommand).IsAssignableFrom(propertyInfo.PropertyType)) { if (string.Equals(propertyInfo.Name, this.CommandName, StringComparison.Ordinal)) { command = (ICommand)propertyInfo.GetValue(this.AssociatedObject, null); } } } } return command; } } 您可以使用 EventArgsConverter 和 EventArgsConverterParameter 属性来创建一个简单的 IValueConverter,而不是发明自己的行为,它结合了原始事件参数和通常作为 CommandParameter 传递的对象: public class ContextualEventArgs : EventArgs { public object? Context { get; } public EventArgs OriginalEventArgs { get; } public ContextualEventArgs(EventArgs original, object? context) : base() { Context = context; OriginalEventArgs = original; } } public class ContextualEventArgsConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value is EventArgs args) { return new ContextualEventArgs(args, parameter); } return Binding.DoNothing; } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { throw new NotImplementedException(); } } 然后您可以将通常用作 CommandParameter 的任何内容放入 EventArgsConverterParameter 中。我在具有 ItemsControl.ItemTemplate 的 ComboBox 中使用它,将项目的 DataContext 添加到 SelectionChanged 事件参数: <!-- In Resources: <conv:ContextualEventArgsConverter x:Key="ContextualEventArgsConverter" /> --> <ComboBox ItemsSource="{Binding Source={StaticResource Modes}}" SelectedItem="{Binding Mode, Mode=OneWay}"> <i:Interaction.Triggers> <i:EventTrigger EventName="SelectionChanged"> <i:InvokeCommandAction Command="{Binding CmdItemModeSelectionChanged, Source={StaticResource CommandContainer}}" EventArgsConverter="{StaticResource ContextualEventArgsConverter}" EventArgsConverterParameter="{Binding .}" /> </i:EventTrigger> </i:Interaction.Triggers> </ComboBox> // In ctor: // CmdItemModeSelectionChanged = new DelegateCommand<ContextualEventArgs>(ExecuteItemModeSelectionChanged); private void ExecuteItemModeSelectionChanged(ContextualEventArgs args) { if (args.Context is MyItem item && args.OriginalEventArgs is SelectionChangedEventArgs sc) { if (sc.AddedItems.Count == 1 && sc.AddedItems[0] is Mode newMode && item.Mode != newMode) { ChangeItemMode(item, newMode); } } }

回答 2 投票 0

WPF 文本多重绑定

当我使用多重绑定时,转换器无法正常工作 公共部分类 TestControl : UserControl { 公共 TestClass TimeData{get;set;} 公共测试控制() {

回答 1 投票 0

如何使用 MultiBinding 在上下文菜单中隐藏分隔符?

我在 wpf 树视图上使用上下文菜单,我几乎就可以实现我想要的。在解释问题之前,让我先解释一下上下文菜单的 XAML 定义的作用。 对于每个

回答 3 投票 0

WPF:多重绑定未使用 OnPropertyChanged 进行更新?

我有一个转换器,它接受一个 bool 值,并根据它的真假返回 A 或 B。转换器根据布尔值选择正确的值,但仅在开始时,如果我改变......

回答 1 投票 0

WPF 多绑定按钮。已启用文本框

我是 WPF 的新手,我在网上找不到解决方案。我的问题是我希望仅当四个文本框没有有效性错误时才启用我的按钮。 我的代码是: 我是 WPF 的新手,我在网上找不到解决方案。我的问题是我希望仅当四个文本框没有有效性错误时才启用我的按钮。 我的代码是: <Button Content="Action" Click="Action_Click" > <Button.IsEnabled> <MultiBinding Converter="{StaticResource ValCon}"> <Binding ElementName="textBox1" /> <Binding ElementName="textBox2"/> <Binding ElementName="textBox3"/> <Binding ElementName="textBox4"/> </MultiBinding> </Button.IsEnabled> </Button> 我的多值转换器是这样的: class ValidityConverter : IMultiValueConverter { public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture) { bool b = true; foreach (var x in values) { TextBox y = x as TextBox; if (Validation.GetHasError(y)) { b = false; break; } } return b; } public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture) { throw new NotImplementedException(); } } 我注意到这只在开始时有效。当用户修改其中一个文本框时,它不会。我的值转换器是否需要实施 INotifyPropertyChange?在 WPF 中做这样的事情的正确解决方案是什么?感谢您的帮助。 编辑 我已经做过这样的事情并且它正在工作: <Button Click="Button_Click" > <Button.Style> <Style TargetType="Button"> <Setter Property="IsEnabled" Value="False"/> <Style.Triggers> <MultiDataTrigger> <MultiDataTrigger.Conditions> <Condition Binding="{Binding Path=(Validation.HasError), ElementName=textBox}" Value="False"/> <Condition Binding="{Binding Path=(Validation.HasError), ElementName=textBox1}" Value="False"/> <Condition Binding="{Binding Path=(Validation.HasError), ElementName=textBox2}" Value="False"/> <Condition Binding="{Binding Path=(Validation.HasError), ElementName=textBox3}" Value="False"/> </MultiDataTrigger.Conditions> <Setter Property="IsEnabled" Value="True"/> </MultiDataTrigger> </Style.Triggers> </Style> </Button.Style> </Button> 我所做的是使用您的 MultiTrigger 解决方案,但在我的情况下,我希望仅当 3 个文本框的长度为零时才激活按钮,因此我的解决方案适用于以下代码.. <Button.Style> <Style TargetType="Button"> <Setter Property="IsEnabled" Value="True"/> <Style.Triggers> <MultiDataTrigger> <MultiDataTrigger.Conditions> <Condition Binding="{Binding Path=Text.Length, ElementName=activationKeyTextbox}" Value="0"/> </MultiDataTrigger.Conditions> <Setter Property="IsEnabled" Value="False"/> </MultiDataTrigger> <MultiDataTrigger> <MultiDataTrigger.Conditions> <Condition Binding="{Binding Path=Text.Length, ElementName=serialDayStartbox}" Value="0"/> </MultiDataTrigger.Conditions> <Setter Property="IsEnabled" Value="False"/> </MultiDataTrigger> <MultiDataTrigger> <MultiDataTrigger.Conditions> <Condition Binding="{Binding Path=Text.Length, ElementName=serialNumdaysbox}" Value="0"/> </MultiDataTrigger.Conditions> <Setter Property="IsEnabled" Value="False"/> </MultiDataTrigger> </Style.Triggers> </Style> </Button.Style> 我不会实现 IMultiValueConverter,因为我们在这里没有转换任何东西。 BindingGroup 可以满足您的目的。 使用 MVVM/INotifyPropertyChanged 的同样有效的方法如下:- 将按钮的 IsEnabled 属性绑定到布尔属性(比如 IsValid)。 将所有文本框绑定到不同的属性。 OnPropertyChange 任何这些文本框,调用一个通用函数(比如 Validate()) IsValid 可以根据 Validate() 设置为 true 或 false,这将依次切换(启用/禁用)按钮的状态。 我知道这是旧的,但我有类似的需求,不想编写绑定组和验证...注意这是我的第一个 wpf 应用程序,也是第一次使用 mvvm! <Button Name="AddBtn" Content="Add" Grid.Row="2" Grid.Column="2" Height="30" Width="100" Command="{Binding AddCmd}" CommandParameter="{Binding Pending}" > <Button.IsEnabled> <MultiBinding Converter="{StaticResource multiButtonEnabled}" > <Binding ElementName="tb1" Path="(Validation.Errors)[0]" /> <Binding ElementName="tb2" Path="(Validation.Errors)[0]" /> <Binding ElementName="tb3" Path="(Validation.Errors)[0]" /> </MultiBinding> </Button.IsEnabled> </Button> 转换器看起来像这样 [ValueConversion(typeof(ValidationError), typeof(bool))] class TxtBoxMultiEnableConverter : IMultiValueConverter { public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { int i=0; foreach (var item in values) { if (item as ValidationError != null) { i++; } } if (i!=0) { return false; } return true; } public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture) { throw new NotSupportedException(); } } 我正在使用 IDataErrorInfo 来捕获模型中的错误,并绑定到一个双精度数。 WPF 很好,在绑定时会为您抛出解析错误,但它们并没有真正为您提供挂钩它们以更改显示给用户的消息或为您提供一个属性来检查是否有错误标记的方法很烦人,但这使您可以捕获解析中的错误,而不必检查验证规则中的解析错误。我敢肯定我的无知正在表现出来,但我们都必须从某个地方开始! 正如迈克所说,文本框没有改变。 您可能应该绑定 textbox.Text 属性。 在你的例子中: <Button Content="Action" Click="Action_Click" > <Button.IsEnabled> <MultiBinding Converter="{StaticResource ValCon}"> <Binding ElementName="textBox1" Path="Text"/> <Binding ElementName="textBox2" Path="Text" /> <Binding ElementName="textBox3" Path="Text"/> <Binding ElementName="textBox4" Path="Text"/> </MultiBinding> </Button.IsEnabled> </Button> 免责声明 这是我的第一个 StackOverflow 答案,所以它可能不准确或需要调整以遵循 StackOverflow 协议。 至于这条评论:https://stackoverflow.com/a/23504690/14654255(无法直接评论) 我已经尝试使用这个建议;但是,没有另一种机制来手动更新 MultiBinding 是不够的。 我的建议是: FormConverter.cs: using System; using System.Globalization; using System.Windows; using System.Windows.Controls; using System.Windows.Data; namespace WpfApp.Converters { /// <summary> /// This class will be used to determine whether the form submission button should be enabled /// </summary> [ValueConversion(typeof(Control), typeof(bool))] public class FormConverter : IMultiValueConverter { public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { foreach (Control control in values) { //Relevant inside the scope of the current iteration only string text = null; //Any validation error if (Validation.GetHasError(control)) return false; //No value selected if (control is DatePicker datePicker) if (datePicker.SelectedDate == DateTime.Today) return false; else continue; if (control is ComboBox comboBox) if (comboBox.SelectedIndex == -1) return false; else continue; //Left blank if (control is TextBox textBox) text = textBox.Text; else if (control is PasswordBox passwordBox) text = passwordBox.Password; if (text != null && text.Length == 0) return false; } return true; } public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) { throw new NotSupportedException(); } } } MainWindow.xaml.cs: using System.Windows; using System.Windows.Controls; using System.Windows.Data; namespace WpfApp { class MainWindow : Window { private MultiBindingExpression buttonBinding = null; public MainWindow() { InitializeComponent(); buttonBinding = BindingOperations.GetMultiBindingExpression(button, button.IsEnabledProperty); } private void UpdateButton(object sender, RoutedEventArgs e) { if (registerButtonBinding == null) return; buttonBinding.UpdateTarget(); } } } MainWindow.xaml: <Window x:Class="WpfApp.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:converters="clr-namespace:WpfApp.Converters"> <Window.Resources> <converters:formConverter x:Key="formConverter"/> </Window.Resources> <StackPanel HorizontalAlignment="Center"> <TextBlock Text="First name"/> <TextBox x:Name="firstNameTextBox"/> <Button x:Name="button"> <Button.IsEnabled> <MultiBinding Converter="{StaticResource formConverter}"> <Binding ElementName="firstName"/> </MultiBinding> </Button.IsEnabled> </Button> </StackPanel> </Window> 来源: https://stackoverflow.com/a/23504690/14654255 https://stackoverflow.com/a/19356651/14654255 https://stackoverflow.com/a/5676257/14654255

回答 5 投票 0

带有自定义限定符的匕首多重装订器。

我有一个名为SettingHandler的接口,它负责处理与Android应用内部特定设置相关的事件。 接口SettingHandler { fun onHandleEvent(....

回答 1 投票 0


wpf组合框多重绑定在第一步中无法获得相对源组合框的组合框项目(以编程方式添加或绑定到数据库)

我想通过特定条件禁用组合框的某些项目。对于此问题,我使用了多重绑定。如果我在xaml中描述了combobox的所有项目,那就没有问题。但是我想填充组合框...

回答 1 投票 0

是否可以在WPF的MultiBinding QuickConverter中使用带参数的经典转换器?

是否可以在WPF中将带有参数的经典转换器与QuickConverter MultiBinding一起使用?更清楚地说,我想绑定TextBlock的Text属性以显示这样的文本:

回答 1 投票 1

WPF组框标题中的多绑定

我想为我的组框的标题实现多重绑定。这是我目前的做法: ... [

回答 1 投票 0

在WPF中多重绑定到两个不同的DataContext

在MultiBinding中,如果DataContext设置为VM1,并且C是该属性的属性,是否可以将第二个绑定绑定到另一个不同的DataContext(如VM2)并将其绑定到VM2中的D属性?

回答 2 投票 1

匕首2集多重绑定不适用于Kotlin中的SimpleEntry吗?

下面的多重绑定有效,当提供对作为IntoSet @Provides @IntoSet fun entryOne()时:Pair {val key = randomStringGenerator()val value =“ ...

回答 1 投票 0

在命令参数中发送当前项目和复选框值

我有一个带有HierarchialDataTemplate的TreeView设置。它的ItemsSource绑定到我的视图模型中的Overlay对象的集合,其中每个Overlay都有一个Layer对象的集合(因此...

回答 1 投票 0

WPF:DataTrigger多属性条件

所以我有这个DataTrigger:

回答 1 投票 0

Multibinding生成“无法设置MultiBinding,因为必须指定MultiValueConverter”

我有一个带绑定的按钮,工作正常,见下文:

回答 2 投票 4

ConverterParameter与Multibinding上的绑定

是否可以在MultiBinding中将Converter绑定添加到ConverterParameter?像这样的东西:

回答 2 投票 9

MultiDataTrigger与具有多重绑定的DataTrigger

我遇到过一种情况,我可以通过使用MultiDataTrigger轻松实现相同的功能,或者使用带有MultiBinding的DataTrigger。是否有任何实质性的理由......

回答 2 投票 27

绑定到属性的WPF按钮Convertback IMultiValueConverter不更新值

我在后面的代码中连接了一个切换按钮。我想将isChecked状态从一个按钮绑定到4个视频控件以切换静音功能。我正在使用multibinding绑定...

回答 1 投票 0

是否可以将MultiBinding的targetType传递给子绑定的转换器?

我们有一个奇怪的例子,一个用作MultiBinding的子节点的Binding需要它的Converters Convert方法来知道MultiBinding绑定的最终数据类型。对于常规绑定...

回答 1 投票 -2

© www.soinside.com 2019 - 2024. All rights reserved.