如何修复 MultiBinding 无法设置,因为必须指定 MultiValueConverter
How to fix MultiBinding cannot be set because the MultiValueConverter must be specified
我是 WPF 应用程序的新手。我第一次使用 Material 设计。我想通过更改模板和设置圆角半径来修整按钮,但它抛出了这个异常:
MultiBinding cannot be set because the MultiValueConverter must be
specified.
1.Does 库甚至允许这样做还是我安装错了库?
2.Does 存在一些很棒的库,例如 WinForms(Bunifu,Guna)
这是我的简单 XAML 代码:
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Programming_Manager"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit" x:Class="Programming_Manager.MainWindow"
mc:Ignorable="d">
<Grid>
<Button Content="{materialDesign:PackIcon Kind=HamburgerMenu, Size=50}" HorizontalAlignment="Left" Margin="210,170,0,0" VerticalAlignment="Top" Width="107" Height="95" Style="{StaticResource ResourceKey=MaterialDesignFloatingActionMiniSecondaryLightButton}"/>
<Button Content="Button" HorizontalAlignment="Left" Margin="467,316,0,0" VerticalAlignment="Top" Width="184" Height="64"/>
</Grid>
</Window>
<Application x:Class="Programming_Manager.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:local="clr-namespace:Programming_Manager"
StartupUri="MainWindow.xaml">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Light.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Primary/MaterialDesignColor.DeepPurple.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Accent/MaterialDesignColor.Lime.xaml" />
</ResourceDictionary.MergedDictionaries>
<Style x:Key="RoundButtonTemplate" TargetType="Button">
<Setter Property="Background" Value="DodgerBlue" />
<Setter Property="Foreground" Value="White" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border CornerRadius="20" Background="{TemplateBinding Background}" BorderThickness="1">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center">
</ContentPresenter>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
</Application.Resources>
</Application>
您根本不需要创建自定义模板。 MaterialDesign 有一个 built-in 附加 属性 来自定义按钮的角半径:ButtonAssist.CornerRadius
.
<Button Content="Do it" materialDesign:ButtonAssist.CornerRadius="20"/>
我是 WPF 应用程序的新手。我第一次使用 Material 设计。我想通过更改模板和设置圆角半径来修整按钮,但它抛出了这个异常:
MultiBinding cannot be set because the MultiValueConverter must be specified.
1.Does 库甚至允许这样做还是我安装错了库?
2.Does 存在一些很棒的库,例如 WinForms(Bunifu,Guna)
这是我的简单 XAML 代码:
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Programming_Manager"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit" x:Class="Programming_Manager.MainWindow"
mc:Ignorable="d">
<Grid>
<Button Content="{materialDesign:PackIcon Kind=HamburgerMenu, Size=50}" HorizontalAlignment="Left" Margin="210,170,0,0" VerticalAlignment="Top" Width="107" Height="95" Style="{StaticResource ResourceKey=MaterialDesignFloatingActionMiniSecondaryLightButton}"/>
<Button Content="Button" HorizontalAlignment="Left" Margin="467,316,0,0" VerticalAlignment="Top" Width="184" Height="64"/>
</Grid>
</Window>
<Application x:Class="Programming_Manager.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:local="clr-namespace:Programming_Manager"
StartupUri="MainWindow.xaml">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Light.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Primary/MaterialDesignColor.DeepPurple.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Accent/MaterialDesignColor.Lime.xaml" />
</ResourceDictionary.MergedDictionaries>
<Style x:Key="RoundButtonTemplate" TargetType="Button">
<Setter Property="Background" Value="DodgerBlue" />
<Setter Property="Foreground" Value="White" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border CornerRadius="20" Background="{TemplateBinding Background}" BorderThickness="1">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center">
</ContentPresenter>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
</Application.Resources>
</Application>
您根本不需要创建自定义模板。 MaterialDesign 有一个 built-in 附加 属性 来自定义按钮的角半径:ButtonAssist.CornerRadius
.
<Button Content="Do it" materialDesign:ButtonAssist.CornerRadius="20"/>