Reputation: 51
I am upgrading a wpf .netframework 4.7 app that uses MahApps.Metro style to a wpf .netcoreapp3.1 app. Afterthe migration I an getting:
System.Windows.Markup.XamlParseException: ''Provide value on 'System.Windows.StaticResourceExtension' threw an exception.
Exception: Cannot find resource named 'MetroButton'. Resource names are case sensitive.
<ResourceDictionary.MergedDictionaries>
<!-- MahApps.Metro resource dictionaries. Make sure that all file names are Case Sensitive! -->
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/VS/Colors.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/VS/Button.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/VS/Styles.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
<ResourceDictionary>
<!--Button-->
<Style x:Key="SmallButtonStyle" TargetType="Button" BasedOn="{StaticResource MetroButton}">
<Setter Property="Height" Value="40" />
<Setter Property="Width" Value="200" />
<Setter Property="Margin" Value="5,2" />
<Setter Property="FontSize" Value="14" />
</Style>
<Style x:Key="StandardButtonStyle" TargetType="Button" BasedOn="{StaticResource MetroButton}">
<Setter Property="Height" Value="50" />
<Setter Property="Width" Value="350" />
<Setter Property="Margin" Value="10,5" />
<Setter Property="FontSize" Value="20" />
</Style>
This worked with MahApps.Metro version 1.65 under .netframework 4.7 but with MahApps.Metro 2.0.0-alpha0748 I get the exception.
Upvotes: 1
Views: 835
Reputation: 51
Solution: change MetroButton to MahApps.Styles.Button
<Style x:Key="SmallButtonStyle" TargetType="Button" BasedOn="{StaticResource MahApps.Styles.Button}">
<Setter Property="Height" Value="40" />
<Setter Property="Width" Value="200" />
<Setter Property="Margin" Value="5,2" />
<Setter Property="FontSize" Value="14" />
</Style>
Upvotes: 3