'How to bind a ButtonAssist CornerRadius Value of Material Design from a source
I'm using C# WPF with Material Design .
What I need :
I'm trying to set CornerRadius of ButtonAssist for any Button in my project.
Problem:
I can't set this property from Application.Resources.
My 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:MaterialDesignation"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
x:Class="MaterialDesignation.MainWindow"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Window.Resources>
</Window.Resources>
<Grid>
<!--I Want to Set Radius For All Buttons in My Projects like blow line ↓-->
<Button Content="Button" materialDesign:ButtonAssist.CornerRadius="30" HorizontalAlignment="Left" Margin="71,260,0,0" VerticalAlignment="Top" Width="237" Height="85" Background="#FF038BEA" BorderBrush="{x:Null}"/>
<Button Content="Button" Style="{StaticResource ResourceKey=Gerdy}" HorizontalAlignment="Left" Margin="410,129,0,0" VerticalAlignment="Top" Width="237" Height="85" Background="#FF038BEA" BorderBrush="{x:Null}"/>
<Button Content="Button" materialDesign:ButtonAssist.CornerRadius="{Binding Gerdy}" HorizontalAlignment="Left" Margin="71,129,0,0" VerticalAlignment="Top" Width="237" Height="85" Background="#FF038BEA" BorderBrush="{x:Null}"/>
</Grid>
My App.xaml :
<Application x:Class="MaterialDesignation.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:clr="clr-namespace:System;assembly=mscorlib"
xmlns:local="clr-namespace:MaterialDesignation"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
StartupUri="MainWindow.xaml">
<Application.Resources>
<ResourceDictionary>
<Style x:Key="Gerdy" TargetType="{x:Type Button}">
<Style.Resources>
<Style TargetType="{x:Type Button}">
<Setter Property="materialDesign:ButtonAssist.CornerRadius" Value="30" />
</Style>
</Style.Resources>
</Style>
<clr:Byte x:Key="GerdyAsByte">30</clr:Byte>
<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>
</ResourceDictionary>
</Application.Resources>
Here is my full WPF project link : https://ufile.io/gt5dcjzh
Please help
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
