gpt4 book ai didi

c# - Material Design 风格 PackIcon

转载 作者:行者123 更新时间:2023-12-04 03:19:58 25 4
gpt4 key购买 nike

我使用 Material Design 创建了一个 UserControl 按钮,基于背后的方法我想通过更改图标来重用模板。我试图将 materialdesign:Packicon 添加到 UserControl.Resources 中,但似乎是错误的。属性样式已在使用中。我怎样才能实现我的图标更改?

<UserControl x:Class="MaterialDesignTest1.UserControl2"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
mc:Ignorable="d" d:DesignWidth="300" Height="132">
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Button.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>

</UserControl.Resources>
<Grid>
<Grid Height="132" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />

</Grid.RowDefinitions>
<!-- Header -->
<Button Grid.Row="0" Grid.Column="0" Background="WhiteSmoke" BorderBrush="LightGray" Style="{StaticResource MaterialDesignFloatingActionMiniAccentButton}"
HorizontalAlignment="Center" VerticalAlignment="Center" Margin="1,1,1,1" Width="50" Height="50">
<materialDesign:PackIcon Height="30" Width="30" Kind="BluetoothConnect" />
</Button>

</Grid>

最佳答案

在后面的代码中,新建一个packicon,设置按钮的内容如下:

PackIcon packIcon = new PackIcon();
packIcon.Kind = PackIconKind.FullscreenExit;
btnResizeDashboard.Content = packIcon;

关于c# - Material Design 风格 PackIcon,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38974803/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com