Home > Enterprise >  How to fix MultiBinding cannot be set because the MultiValueConverter must be specified
How to fix MultiBinding cannot be set because the MultiValueConverter must be specified

Time:03-15

I'm new to the WPF app. I used Material Design for the first time. I wanted to round off the button by changing the template and setting the corner radius, but it threw this exception:

MultiBinding cannot be set because the MultiValueConverter must be specified.

1.Does the library even allow this or did I install the library wrong?

2.Does exist some great library like in WinForms(Bunifu,Guna)

Here is my simple XAML code:

<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>

CodePudding user response:

You do not need to create a custom template at all. MaterialDesign has a built-in attached property to customize the corner radius of a button: ButtonAssist.CornerRadius.

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