我是 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>
uj5u.com熱心網友回復:
您根本不需要創建自定義模板。MaterialDesign 有一個內置的附加屬性來自定義按鈕的圓角半徑:ButtonAssist.CornerRadius.
<Button Content="Do it" materialDesign:ButtonAssist.CornerRadius="20"/>
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/443819.html
