Use Material Design and Caliburn.Micro simalteniously - c#

I use WPF, and C#. I want to use both :MaterialDesign and Caliburn.Micro v4.0173 in one solution in Visual Studio. I have tried to add both of them to App.xaml, but materialDesign does not work. So the view of controls is the same as if I don't installed materialDesign.
<Application x:Class="WPFUI.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WPFUI">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary>
<local:Bootstrapper x:Key="Bootstrapper"/>
<ResourceDictionary x:Key="MD1" Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Light.xaml" />
<ResourceDictionary x:Key="MD2" Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml" />
<ResourceDictionary x:Key="MD3" Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Primary/MaterialDesignColor.BlueGrey.xaml" />
<ResourceDictionary x:Key="MD4" Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Accent/MaterialDesignColor.Lime.xaml" />
<ResourceDictionary x:Key="MD5" Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.DataGrid.ComboBox.xaml" />
</ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>

Related

Application work in processes without startup - WPF

I have a WPF application which has a daily restart timer, after daily restarting the application doesn't open, it is only appear in processes (taskbar for Win7) but not applications bar.
There is no logged exception, also I logged a string in the beginning of startup function but also not logged.
<Application
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:Kiosk.Controls"
xmlns:converters="clr-namespace:Wpf.Controls.Converters;assembly=Wpf.Controls"
x:Class="Kiosk.App"
StartupUri="MainWindow.xaml" Startup="Application_Startup">
<Application.Resources>
<!-- Resources scoped at the Application level should be defined here. -->
<ResourceDictionary>
<converters:InverBooleanToVisibilityConverter x:Key="InverBooleanToVisibilityConverter"/>
<converters:IntToVisibilityConverter x:Key="IntToVisibilityConverter"/>
<converters:InverseBooleanConverter x:Key="InverseBooleanConverter"/>
<controls:FlowDocumenConverter x:Key="FlowDocumenConverter"/>
<controls:NullToImageConverter x:Key="NullToImageConverter" />
<FontFamily x:Key="DuBoldFont">pack://application:,,,/Font/#du Co Headline 16 iOS</FontFamily>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Themes/Default/001DefaultStyle.xaml"/>
<ResourceDictionary Source="Themes/Default/002Decorations.xaml"/>
<ResourceDictionary Source="Themes/Default/003Buttons.xaml"/>
<ResourceDictionary Source="Themes/Default/004LanguageButton.xaml"/>
<ResourceDictionary Source="Themes/Default/005ScrollViwer.xaml"/>
<ResourceDictionary Source="Themes/Default/006Window.xaml"/>
<ResourceDictionary Source="Themes/Default/007Pager.xaml"/>
<ResourceDictionary Source="Themes/Default/008ListView.xaml"/>
<ResourceDictionary Source="Themes/Default/009ProgressBar.xaml"/>
<ResourceDictionary Source="Themes/Default/010EnterLabel.xaml"/>
<ResourceDictionary Source="Themes/Default/011TextBlock.xaml"/>
<ResourceDictionary Source="Themes/Default/012FlowDocument.xaml"/>
<ResourceDictionary Source="Themes/Default/013EnterStringView.xaml"/>
<ResourceDictionary Source="Themes/Default/014MakeRequestStyle.xaml" />
<ResourceDictionary Source="Themes/Default/015InvoiceEnterMoney.xaml" />
<ResourceDictionary Source="Themes/Default/016ImageButton.xaml" />
<ResourceDictionary Source="Themes/Default/017Browser.xaml" />
<ResourceDictionary Source="Themes/Default/018Logo.xaml" />
<ResourceDictionary Source="Themes/Default/019TitleLogo.xaml" />
<ResourceDictionary Source="Themes/Default/020TransactionInformation.xaml" />
<ResourceDictionary Source="Themes/Default/021Keyboards.xaml" />
<ResourceDictionary Source="Themes/Default/022EnterPhoneView.xaml" />
<ResourceDictionary Source="Themes/Default/023ConfirmInvoiceView.xaml" />
<ResourceDictionary Source="Themes/Default/024IndoorInfoEntry.xaml"></ResourceDictionary>
<ResourceDictionary Source="Themes/Default/025CertifyInvoiceView.xaml"></ResourceDictionary>
<ResourceDictionary Source="Themes/Default/026ConfirmInputData.xaml"/>
<ResourceDictionary Source="Themes/Default/027ShowBarCodeView.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>

Mahapps using VS Styles throws IOException

I'm using Mahapps Tabcontrol in my WPF application. When I use the default styling it works well, if I try to use the VS Styles in the App.xaml:
<Application x:Class="UI.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=mscorlib"
xmlns:vm="clr-namespace:UI.ViewModel"
xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
xmlns:local="clr-namespace:UI"
StartupUri="MainWindow.xaml">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<!-- MahApps.Metro resource dictionaries. Make sure that all file names are Case Sensitive! -->
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml" />
<!-- Accent and AppTheme setting -->
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/Teal.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseDark.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/VS/Controls.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/VS/Colors.xaml" />
<!-- Icons -->
<ResourceDictionary x:Name="IconsDictionary" Source="Resources/Dictionary.xaml"/>
</ResourceDictionary.MergedDictionaries>
<system:Double x:Key="WindowTitleFontSize">16</system:Double>
<FontFamily x:Key="HeaderFontFamily">Segoe UI</FontFamily>
<vm:ViewModelLocator x:Key="MainLocator"/>
</ResourceDictionary>
</Application.Resources>
...it throws an error: IOException: Cannot locate resource 'styles/vs/controls.xaml'.
If I remove the VS/Styles reference from the App.xaml the application compiles.
Found a fix!
First, removed the VS/Styles from the App.xaml:
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<!-- MahApps.Metro resource dictionaries. Make sure that all file names are Case Sensitive! -->
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml" />
<!-- Accent and AppTheme setting -->
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/Teal.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseDark.xaml" />
<!-- Icons -->
<ResourceDictionary x:Name="IconsDictionary" Source="Resources/Dictionary.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
Second, moved it to the MainWindow.xaml under Window.Resources:
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/VS/Colors.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/VS/Styles.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources>
Found the fix here resources are not defined in 'Styles\VS\Colors.xaml'

WPF MahApps.Metro Resources not found

I updated the Packages recently and since then my recourses are not found anymore.
Only the Controls and the Fonts are found but not the rest which i find really confusing.
Did anyone had a similar problem?
BR Max
<Application x:Class="Tools.Shell.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Tools.Shell">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<!-- MahApps.Metro resource dictionaries. Make sure that all file names are Case Sensitive! -->
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml" />
<!-- Accent and AppTheme setting -->
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/Teal.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml" />
<!-- Button Theme setting -->
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/FlatButton.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
This is a case of. when you upgrade a package, always check the documents for breaking changes
Migration to v2.0
Theming
The theming got rewritten, this means that there is no longer a
separation between AppTheme and Accent. These got replaced by Theme
everywhere. Instead of something like
pack://application:,,,/MahApps.Metro;component/Styles/Accents/Blue.xaml
and
pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml
you now have to use
pack://application:,,,/MahApps.Metro;component/Styles/Themes/Light.Blue.xaml.
Old
<Application x:Class="WpfApplication.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/Blue.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
New
<Application x:Class="WpfApplication.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Themes/Light.Blue.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
Note : I don't use this package (or any of his stuff), there may be more to this story, however at least it might point you in the right direction. You need to read the rest of the documentation about migration

How to apply MaterialDesignInXAML to only one control

I want to use the MaterialDesignInXAML for some elements of my WPF application, but i don't want to apply the theme to the whole apps (i'm particularly interested in the buttons)
So how do use the theme without applying this to App.xaml:
<Application . . . >
<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.DeepPurple.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Accent/MaterialDesignColor.Lime.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
You Should Add ResourceDictionary lines in your UserControl
<Button x:Class="MyButton">
<Button.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.DeepPurple.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Accent/MaterialDesignColor.Lime.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Button.Resources>
</Button>
and use MyButton
<MyButton></MyButton>
Only reference the button resources: MaterialDesignTheme.Button.xaml:
<Application>
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Button.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
All the styles are not implicit and must be referenced explicitly as {StaticResource}. You can check the source file on GitHub to know which styles (keys) are available.

MergedDictionaries nightmare

I'm trying to use a WPF Template and I'm supposed to include this in my App.xaml, but I get "Nested properties are not supported: ResourceDictionaries.MergedDictionaries" error and "The attachable property "MergedDictionaries" was not found in type "ResourceDictionary".
<Application x:Class="Unico.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml">
<Application.Resources>
<ResourceDictionary.MergedDictionaries>
<!-- Set default skin -->
<ResourceDictionary Source="\ExpressionDark.xaml"/>
<ResourceDictionary Source="\WindowStyle.xaml"/>
</ResourceDictionary.MergedDictionaries>
<Style TargetType="{x:Type Rectangle}" />
</Application.Resources>
</Application>
I've tried everything but still can't fix this. Any idea? Thanks.
MergedDictionaries is a property of ResourceDictionary.
Change to:
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
...
</ResourceDictionary.MergedDictionaries>
<Style TargetType="{x:Type Rectangle}" />
</ResourceDictionary>
</Application.Resources>

Categories

Resources