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'
Related
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>
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>
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
i'm trying to convert my application wpf application from .net framework 4.8 to .net core.
I have a a class library .net core 3.1, where i put all my themes, styles, languages and other resources, when i try to run it breaks because itcan't find my resource
IOException: Cannot locate resource 'windows/vulpesaccesswindow.xaml'.
in my app.xaml i have this:
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Telerik.Windows.Themes.VisualStudio2013;component/Themes/System.Windows.xaml" />
<ResourceDictionary Source="/Telerik.Windows.Themes.VisualStudio2013;component/Themes/Telerik.Windows.Controls.xaml" />
<ResourceDictionary Source="/Telerik.Windows.Themes.VisualStudio2013;component/Themes/Telerik.Windows.Controls.Input.xaml" />
<ResourceDictionary Source="/Telerik.Windows.Themes.VisualStudio2013;component/Themes/Telerik.Windows.Controls.Data.xaml" />
<ResourceDictionary Source="/Telerik.Windows.Themes.VisualStudio2013;component/Themes/Telerik.Windows.Controls.DataVisualization.xaml" />
<ResourceDictionary Source="/Telerik.Windows.Themes.VisualStudio2013;component/Themes/Telerik.Windows.Controls.Diagrams.xaml" />
<ResourceDictionary Source="/Telerik.Windows.Themes.VisualStudio2013;component/Themes/Telerik.Windows.Controls.Navigation.xaml" />
<ResourceDictionary Source="/Telerik.Windows.Themes.VisualStudio2013;component/Themes/Telerik.Windows.Controls.Diagrams.Extensions.xaml" />
<ResourceDictionary Source="/Telerik.Windows.Themes.VisualStudio2013;component/Themes/Telerik.Windows.Controls.Docking.xaml" />
<ResourceDictionary Source="/Telerik.Windows.Themes.VisualStudio2013;component/Themes/Telerik.Windows.Controls.GanttView.xaml" />
<ResourceDictionary Source="/Telerik.Windows.Themes.VisualStudio2013;component/Themes/Telerik.Windows.Controls.GridView.xaml" />
<ResourceDictionary Source="/Telerik.Windows.Themes.VisualStudio2013;component/Themes/Telerik.Windows.Controls.Pivot.xaml" />
<ResourceDictionary Source="/Telerik.Windows.Themes.VisualStudio2013;component/Themes/Telerik.Windows.Controls.PivotFieldList.xaml" />
<ResourceDictionary Source="/Telerik.Windows.Themes.VisualStudio2013;component/Themes/Telerik.Windows.Controls.ScheduleView.xaml" />
<!--TELERIK-->
<!--UIX-->
<ResourceDictionary Source="/UIX;component/Windows/VulpesAccessWindow.xaml" />
<ResourceDictionary Source="/UIX;component/Windows/VulpesShellWindow.xaml" />
<ResourceDictionary Source="/UIX;component/Windows/VulpesDialogWindow.xaml" />
<ResourceDictionary Source="/UIX;component/Resources/ThemeLight.xaml" />
<ResourceDictionary Source="/UIX;component/Resources/BaseColors.xaml" />
<ResourceDictionary Source="/UIX;component/Resources/Icons.xaml" />
<ResourceDictionary Source="/UIX;component/Resources/VulpesTelerik.xaml" />
<ResourceDictionary Source="/UIX;component/Resources/Labels.xaml" />
<ResourceDictionary Source="/UIX;component/Resources/Navigation.xaml" />
<ResourceDictionary Source="/UIX;component/Resources/Validation.xaml" />
<ResourceDictionary Source="/UIX;component/Resources/Templates.xaml" />
<ResourceDictionary>
<local:ShellBootstrapper x:Key="bootstrapper" />
</ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
i try to set my resource VulpesAccessWindow.xaml Build Action to Resource and Embedded Resource, but nothing, when i run it breaks..
Any advice?
Thank you
Using the full pack notation works in a solution I have:
<ResourceDictionary Source="pack://application:,,,/UILib;component/Resources/FontResources.xaml"/>
In the library, this is Build Action Page.
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.