C# 多重绑定、转换器和设置器:意外错误

C# 多重绑定、转换器和设置器:意外错误,c#,wpf,binding,multibinding,C#,Wpf,Binding,Multibinding,我试图在WPF中为按钮使用多重绑定样式,但遇到了一个棘手的错误: System.ArgumentException:''System.Drawing.SolidBrush'n'est pas une valeur valide pour la propriététés'System.Windows.Controls.Panel.Background'd'une méthode Setter' 但我正在将我的设置应用于Button.BackgroundProperty 以下是多重绑定: &

我试图在WPF中为按钮使用多重绑定样式,但遇到了一个棘手的错误: System.ArgumentException:''System.Drawing.SolidBrush'n'est pas une valeur valide pour la propriététés'System.Windows.Controls.Panel.Background'd'une méthode Setter'

但我正在将我的设置应用于Button.BackgroundProperty

以下是多重绑定:

    <Button
                            Height="20"
                            Margin="2,0,2,2"
                            VerticalAlignment="Bottom"
                            Click="Btn_summary_OnClick"
                            Content="Résumé"
                            Name="btn_summary">
                            <Button.Style>
                                <MultiBinding Converter="{StaticResource StyleConverter1}">
                                    <Binding ElementName="listBoxBooks" Path="SelectedItem" />
                                    <Binding Source="{StaticResource bookManagement}" Path="SelectedTab" Mode="OneWay"/>
                                    <Binding RelativeSource="{RelativeSource Self}" Path="Name"/>
                                </MultiBinding>
                            </Button.Style>
                        </Button>
我不明白为什么VS想要将我的设置器应用于面板


谢谢

系统。绘图
是Winforms的名称空间。删除此项并替换为WPF等效的
System.Windows.Media
,然后使用正确的类

System.Drawing
是Winforms的名称空间。删除此项并替换为WPF等效的
System.Windows.Media
,然后使用正确的类

有关更多问题,请提供英文错误消息。这样,更多的人能够理解你的问题。(在这种情况下,文本并不重要,只是为将来的问题做准备)对于进一步的问题,请用英语提供错误消息。这样,更多的人能够理解你的问题。(在这种情况下,文本没有那么重要,只是为将来的问题做准备)
    public class StyleConverter1 : IMultiValueConverter
    {

        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            Style styleToApply = new Style(typeof(Button));

            Object selectedItem = values[0];
            if (selectedItem == null)
            {
                styleToApply.Setters.Add(new Setter(Button.IsEnabledProperty, false));
                return styleToApply;
            }




            styleToApply.Setters.Add(new Setter(Button.IsEnabledProperty, true));

            string selectedTab = values[1] as string;
            if (selectedTab == null)
            {
                return styleToApply;
            }


            string buttonName = values[2] as string;
            if ((selectedTab.Equals("summary") && buttonName.Equals("btn_summary"))
                || (selectedTab.Equals("end") && buttonName.Equals("btn_end"))
                || (selectedTab.Equals("amazon") && buttonName.Equals("btn_amazon"))
                )
            {
                styleToApply.Setters.Add(new Setter(Button.BackgroundProperty,Brushes.Yellow));
                styleToApply.Setters.Add(new Setter(Button.ForegroundProperty, Brushes.RoyalBlue));
            }
            else
            {
                styleToApply.Setters.Add(new Setter(Button.ForegroundProperty, Brushes.Yellow));
                styleToApply.Setters.Add(new Setter(Button.BackgroundProperty, Brushes.RoyalBlue));
            }

            return styleToApply;
        }

        public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }


    }