无法设置如何修复MultiBinding,因为必须指定MultiValueConverter



我是WPF应用程序的新手。我第一次使用材料设计。我想通过更改模板和设置拐角半径来完善按钮,但它抛出了这个异常:

无法设置MultiBinding,因为MultiValueConverter必须指定。

1.库是否允许这样做,或者我是否安装错了库

2.是否存在一些伟大的库,如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有一个内置的附加特性,用于自定义按钮的圆角半径:ButtonAssist.CornerRadius

<Button Content="Do it" materialDesign:ButtonAssist.CornerRadius="20"/>

相关内容

  • 没有找到相关文章

最新更新