I got a button (using MaterialDesign theme) in a WPF form button that is not styling correctly, where am I going wrong?. The button in the DataGrid is fine. I tried near Window on mainWindow doing Foreground="white" but when I take the theme off everything returns to nornal WPF form with the text colour (lower right) missing
app.xamp:
<Application x:Class="App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:P2Assessment"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
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.Purple.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Button.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Accent/MaterialDesignColor.Blue.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
main window with the frame:
<Window x:Name="frmMain" x:Class="mainWindow"
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:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
TextElement.Foreground="{DynamicResource MaterialDesignBody}"
TextElement.FontWeight="Regular"
TextElement.FontSize="13"
TextOptions.TextFormattingMode="Ideal"
TextOptions.TextRenderingMode="Auto"
Foreground="White"
Background="{DynamicResource MaterialDesignPaper}"
FontFamily="{DynamicResource MaterialDesignFont}"
xmlns:local="clr-namespace:P2Assessment"
mc:Ignorable="d"
Title="XYZ & Co." Height="460" Width="800">
<Grid>
<materialDesign:Card Margin="16">
<Frame x:Name="frame" Margin="10,15,10,5">
<!-- navigate to different views-->
</Frame>
</materialDesign:Card>
</Grid>
frame navigating page:
<Page x:Class="P2Assessment.ViewOrders"
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"
Foreground="Wheat"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"
Title="ViewOrders">
<Grid>
<StackPanel>
<Label Content="View orders" FontSize="28" FontWeight="Bold" HorizontalAlignment="Center"/>
<DataGrid x:Name="dgOrders" AutoGenerateColumns="False" Height="260">
<DataGrid.Columns>
<DataGridTextColumn Header="Id" Binding="{Binding Id}" Width="15"/>
<DataGridTextColumn Header="Date / Time" Binding="{Binding dateTime}" Width="200"/>
<DataGridTextColumn Header="# Items" Binding="{Binding Items}" Width="200"/>
<DataGridTextColumn Header="Total" Binding="{Binding Total}" Width="75"/>
<DataGridTemplateColumn>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Button Content="View order details" Click="ViewOrderDetails"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,15,0,0" >
<Button Content="Add an order" Margin="0,0,15,0" Padding="15" Click="AddOrderClicked" Style="{StaticResource MaterialDesignRaisedAccentButton}" Width="100"/>
<Button Content="Close" Margin="0,0,15,0" Padding="15" Click="Button_Click"/>
</StackPanel>
</StackPanel>
</Grid>
Thanks for your help
it was because of Padding="15"
must've pushed the content outside the button area