I try to find a way to display an icon from the material design nugget to my buttons programmatically, I made some progress but I think the most important problem is that I don't have this line "Style="{StaticResource MaterialDesignFloatingActionMiniAccentButton}"
from XAML in my C# Code, and I don't know how to implement this.
This is my Button in XAML:
<Button
x:Name="AddRowInHexConverter"
Grid.Row="0"
Grid.Column="4"
Width="20"
Height="20"
Margin="0,0,0,0"
HorizontalAlignment="Center"
VerticalAlignment="Bottom"
Background="#FF2196F3"
BorderBrush="#FF2196F3"
Click="AddRowInHexConverter_Click"
Foreground="White"
Style="{StaticResource MaterialDesignFloatingActionMiniAccentButton}">
<materialDesign:PackIcon
Width="20"
Height="20"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Kind="Add" />
<Button.Resources>
<Style TargetType="Border">
<Setter Property="CornerRadius" Value="5" />
</Style>
</Button.Resources>
</Button>
and look like this:
This is my button in C#:
Button deleteRow = new Button();
deleteRow.Width = 20;
deleteRow.Height = 20;
deleteRow.HorizontalAlignment = HorizontalAlignment.Center;
deleteRow.VerticalAlignment = VerticalAlignment.Bottom;
deleteRow.Background = (SolidColorBrush)new BrushConverter().ConvertFrom("#FF2196F3");
deleteRow.Foreground = new SolidColorBrush(Colors.White);
deleteRow.BorderBrush = (SolidColorBrush)new BrushConverter().ConvertFrom("#FF2196F3");
deleteRow.Click += DeleteRowFromGrid_Click;
PackIcon icon = new PackIcon();
icon.Kind = PackIconKind.Minus;
icon.Foreground = new SolidColorBrush(Colors.White);
icon.Height = 20;
icon.Width = 20;
icon.HorizontalAlignment = HorizontalAlignment.Center;
icon.VerticalAlignment = VerticalAlignment.Center;
deleteRow.Content = icon;
and look like this:
I also done this but seems to doesn't work:
Style = Resources["MaterialDesignFloatingActionMiniAccentButton"] as Style