MahApps / mahapps.com

New web site for MahApps.Metro
https://mahapps.com
MIT License
19 stars 32 forks source link

Need documentation on some missing styles after migration (1.6.5 => 2.0.0) #3

Closed ghost closed 3 years ago

ghost commented 4 years ago

I'm migrating my .NET 4.7.2 WPF application using MahApps.Metro 1.6.5 to .NET Core 3.0 using MahApp.Metro 2.0.0-alpha0531 and some of my styles that were working fine simply break at runtime with the newest version.

I've carefullly watched the documentation and searched for those missing styles but couldn't find any equivalent/migration guide for these particular components.

timunie commented 4 years ago

Hi @bbougot The documentation is in work. You need to search in the source code at the moment. I have made a list which is a good starting point but incomplete MahApps/MahApps.Metro#3644

Happy coding Tim

ghost commented 4 years ago

Hi @timunie, thanks for the tip!

I actually may have spoken a bit fast, I've finally successfully found equivalents to my previous MahApps styles:

As a side note, I'm still blown away by the huge quality of this framework, definitely (subjective) best WPF framework out there. Congrats @punker76 (and also @timunie)

Gerardo-Sista commented 4 years ago

Hello, same problem here with version 2. This code worked fine with 1.6.5:

   <Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource MetroTextBox}" >
            <Setter Property="FontSize" Value="20" />
            <Setter Property="FontFamily" Value="Consolas" />
            <Setter Property="FontWeight" Value="Bold" />
            <Setter Property="TextWrapping" Value="Wrap"/>
            <Setter Property="MinWidth" Value="50"/>
            <Setter Property="BorderBrush" Value="{DynamicResource AccentBaseColorBrush}" />
            <Setter Property="mah:TextBoxHelper.ClearTextButton" Value="True" />
            <Setter Property="mah:TextBoxHelper.UseFloatingWatermark" Value="True"/>
            <Setter Property="mah:TextBoxHelper.SelectAllOnFocus" Value="True"/>

            <Setter Property="val:ValidationsHelper.Property" Value="Text"/>
            <Style.Triggers>
                <Trigger Property="Validation.HasError" Value="True">
                    <Setter Property="ToolTip" Value="{Binding RelativeSource={RelativeSource Self}, Path=(Validation.Errors)[0].ErrorContent}"/>
                </Trigger>
            </Style.Triggers>
        </Style>

but now, if I change with this:

<Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource MahApps.Styles.TextBox}" >

nothing works (also brushes need to be changed)

....could you guys @bbougot or @timunie provide the full version 2.0 example for this style please? I think it would be useful for everyone (specially unesperienced people like me).

Any help would be appreciated Thank you

superlloyd commented 4 years ago

I have the exact same problem! I haven't touched the application in a while and I have a hard time guessing what those style can be... (EDIT: Thanks Git Branches I found the resources again in the net40 branch!)

What about? AccentColorBrush4 GrayNormal

timunie commented 4 years ago

Hi @superlloyd Have a look here: https://github.com/MahApps/MahApps.Metro/blob/develop/src/MahApps.Metro/Styles/Themes/Theme.Template.xaml

Happy coding Tim

paatrickd commented 4 years ago

I am having a similar problem with creating custom accents and adding them to a theme.

In version 1.6.5 I created an custom accent in MyCustomTheme.xaml (I have found the new resource keys to update this .xaml) and used this by using ThemeManager with following code.

public partial class App : Application
{
    protected override void OnStartup(StartupEventArgs e)
    {
            ThemeManager.AddAccent("CustomAccent1", new Uri("pack://application:,,,/Resources/MyCustomTheme.xaml"));
            Tuple<AppTheme, Accent> theme = ThemeManager.DetectAppStyle(Application.Current);
            ThemeManager.ChangeAppStyle(Current, ThemeManager.GetAccent("CustomAccent1"), theme.Item1);
            base.OnStartup(e);
    }
}

However this does not work because methods in ThemeManager have changed. How is this done in v2.0.0?

punker76 commented 3 years ago

@bbougot @superlloyd The migration guide can be found here https://mahapps.com/docs/guides/migration-to-v2.0

@Gerardo-Sista Here is the full converted style:

<Style BasedOn="{StaticResource MahApps.Styles.TextBox}" TargetType="{x:Type TextBox}">
    <Setter Property="FontSize" Value="20"/>
    <Setter Property="FontFamily" Value="Consolas"/>
    <Setter Property="FontWeight" Value="Bold"/>
    <Setter Property="TextWrapping" Value="Wrap"/>
    <Setter Property="MinWidth" Value="50"/>
    <Setter Property="BorderBrush" Value="{DynamicResource MahApps.Brushes.AccentBase}"/>
    <Setter Property="mah:TextBoxHelper.ClearTextButton" Value="True"/>
    <Setter Property="mah:TextBoxHelper.UseFloatingWatermark" Value="True"/>
    <Setter Property="mah:TextBoxHelper.SelectAllOnFocus" Value="True"/>
    <Setter Property="val:ValidationsHelper.Property" Value="Text"/>
    <Style.Triggers>
        <Trigger Property="Validation.HasError" Value="True">
            <Setter Property="ToolTip" Value="{Binding RelativeSource={RelativeSource Self}, Path=(Validation.Errors)[0].ErrorContent}"/>
        </Trigger>
    </Style.Triggers>
</Style>

@paatrickd Here are the links for the ThemeManager stuff: