resourcedictionary

Merging Resources Dictionaries

﹥>﹥吖頭↗ 提交于 2019-12-07 00:51:49
问题 i'm trying merging wpf resource dictionaries on the code behind but for some reasion this isn't working. If i try merge the dictionaries on the document itself it's running for instance: <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:WpfApplication212;assembly=WpfApplication212"> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="Theme.xaml"><

Error when using x:Shared=“False” resources in external assembly in WPF

主宰稳场 提交于 2019-12-06 23:58:07
问题 In our project we have a ResourceDictionary with some Icons that looks like this: <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <Canvas x:Key="Icon.Refresh" x:Shared="False" Width="32" Height="32" Clip="F1 M 0,0L 32,0L 32,32L 0,32L 0,0"> <Path .../> <Path .../> <Path .../> </Canvas> </ResourceDictionary> The x:Shared="False" attribute is needed, because else the icon would disappear when I use it

how to use styles defined in ResourceDictionary

柔情痞子 提交于 2019-12-06 23:49:35
问题 I have several common styles and I want to share them in several pages of my Windows 8.1 application. I know that I can achieve with merge dictionaries option, but I have no idea how to use styles defined in dictionary. I tried this: <Page.Resources> <ResourceDictionary x:Key="lol"> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="Themes/Generic.xaml" /> <ResourceDictionary> <Style x:Key="TextViewAllStyle" TargetType="TextBlock"> </Style> </ResourceDictionary> <

How to change UI language using resource dictionary at run time?

北慕城南 提交于 2019-12-06 15:54:18
I want to change my project language by button_click event, so I use ResourceDictionary to do it like this: XAML <Button Content="{DynamicResource LanguageSetting}" Click="btn_LanguageSetting_Click"/> Code Behind public static string windowCurrentLanguageFile = "Language/en.xaml"; private void btn_LanguageSetting_Click(object sender, RoutedEventArgs e) { windowCurrentLanguageFile = windowCurrentLanguageFile == "Language/en.xaml" ? "Language/fr.xaml" : "Language/en.xaml"; var rd = new ResourceDictionary() { Source = new Uri(windowCurrentLanguageFile, UriKind.RelativeOrAbsolute) }; if (this

Access ResourceDictionary by name

若如初见. 提交于 2019-12-06 15:24:34
Lets say I have some ResourceDictionary's in my Application.xaml defined as so: <Application> <Application.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary x:Name="brushResources"/> <ResourceDictionary x:Name="graphicsResources"/> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> </Application.Resources> </Application> I would have assumed I could just simply access the dictionary in the code behind like so: brushResources.MergedDictionaries.Add(someNewBrushes) graphicsResources.MergedDictionaries.Add(someNewGraphics) But this does not

Using a global ResourceDictionary in a UserControl Library

佐手、 提交于 2019-12-06 14:52:25
I have have "Project A" with "MyResourceDictionary.xaml" in "App.xaml" <Application.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="MyResourceDictionary.xaml"/> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> </Application.Resources> I want to also use "MyResourceDictionary.xaml" in my user control library - "Project B" Can I do this? Thanks, Eamonn Kent Boogaart Check out the pack URI syntax . Something like: <ResourceDictionary Source="ProjectB;component/MyResourceDictionary"/> @Kent Boogaart Thanks for the help Kent, here is

Access ResourceDictionary in Windows Phone project from Shared project in App.xaml of Universal 8.1 App

眉间皱痕 提交于 2019-12-06 06:37:59
问题 I am creating a Windows Universal 8.1 app. In the Windows Phone 8.1 project inside I have a certain Xaml file as ResourceDictionary. In the Shared Folder I have the common App.xaml of the 2 projects (Windows and Windows Phone). Path of ResourceDictionary is: "MyApp.WindowsPhone/Assets/Styles/JumpList.xaml" In App.xaml I add: <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="MyApp.WindowsPhone/Assets/Styles/JumpList.xaml"/> </ResourceDictionary

XAML - Using fonts from resource dictionary from another assembly

别来无恙 提交于 2019-12-06 06:27:20
问题 I am building an application that uses ResourceDictionaries from another assembilies and I'm having problems with using fonts. There is an assembly named MyFontAssembly that stores fonts along with references to them as an ResourceDictionary . The structure of it looks as follows: MyFontAssembly - FontDictionary.xaml - (stores references to fonts) - Fonts - FontA.ttf - FontB.ttf ... There is also another assembly that stores ResourceDictionaries for styling controls and it's called

How to change ResourceDictionary Dynamically

时光总嘲笑我的痴心妄想 提交于 2019-12-06 06:05:27
I need to change ResourceDictionary in App.xaml file dynamically. I have tried the following code: ResourceDictionary newRes = new ResourceDictionary(); newRes.Source = new Uri("/PsyboInventory;component/TitleBarResource.xaml", UriKind.RelativeOrAbsolute); this.Resources.MergedDictionaries.Clear(); this.Resources.MergedDictionaries.Add(newRes); There is no error, but the theme not change In button click you can write this code var app = (App)Application.Current; app.ChangeTheme(new Uri("New Uri here")); public partial class App : Application { public ResourceDictionary ThemeDictionary { // You

How to add PresentationFramework.Aero theme to ResourceDictionary

不想你离开。 提交于 2019-12-06 04:48:06
I want to add the PresentationFramework.Aero theme to my ResourceDictionary. The ResourceDictionary itself is in one assembly called ProjectResources. Within this assembly I define all my styles for my project. So this ResourceDictionary is used by several different assemblies in my project. So far it worked fine for all my Dictionaries defined. Now i want to add the Aero theme. But I always get the exception: An unhandled exception of type 'System.Windows.Markup.XamlParseException' occurred in PresentationFramework.dll Inner Exception: {"Could not load file or assembly 'PresentationFramework