resourcedictionary

Dynamically loading resource dictionary files to a wpf application gives an error

人走茶凉 提交于 2019-11-27 14:49:11
I am trying to add a xaml resource file dynamically using the statement, Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary() { Source = new Uri("resources/leaf_styles.xaml", UriKind.Relative) }); This is throwing an exception, Cannot locate resource 'resources/leaf_styles.xaml'. I added the leaf_styles.xaml file to the project under resource folder and the BuildAction is set to "Content", CopyAlways is set to True. Still I get this error. Could some one help me out pointing whats wrong?? Additional information - I don't want to embed the xaml file as a resource The

Add ResourceDictionary to class library

流过昼夜 提交于 2019-11-27 13:50:16
问题 I created a class library which is contained of WPF Windows and some user controls inherited from my c# classes that helps me to customize certain wpf controls. Now I want to add ResourceDictionary, to help me share styles between my wpf classes. Is it possible? Thx. EDIT: resource dictionary file located in MY.WpfPresentation.Main project (named Styles.xaml): <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006

Skinning: Using a Color as StaticResource for another Color

孤街浪徒 提交于 2019-11-27 13:25:59
I implemented skinning in my application. The application loads its Brushes.xaml resource dictionary which uses colors which reside in a skin-specific resource dictionary. So only one Color.xaml is loaded depending on the chosen skin. Skin-Specific Color.xaml <Color x:Key="TextBoxBackgroundColor">#C4AF8D</Color> <Color x:Key="TextBoxForegroundColor">#6B4E2C</Color> <Color x:Key="ToolBarButtonForegroundColor">#6B4E2C</Color> Brushes.xaml: <SolidColorBrush x:Key="TextBoxBackground" Color="{DynamicResource TextBoxBackgroundColor}" /> <SolidColorBrush x:Key="TextBoxForeground" Color="

Adding a Merged Dictionary to a Merged Dictionary

半城伤御伤魂 提交于 2019-11-27 12:45:44
I can't seem to be able to add a merged dictionary to a collection of merged dictionaries within XAML. Theme.xaml <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="/Mine;component/Themes/Palette.Blue.xaml"/> <ResourceDictionary Source="/Mine;component/Themes/Template.xaml"/> </ResourceDictionary.MergedDictionaries> Application Resources <Application.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="/Mine;component/Themes/Theme.xaml"/> <!-- <ResourceDictionary Source=="/Mine;component/Themes/Palette.Blue.xaml"/>

Load a ResourceDictionary from an assembly

▼魔方 西西 提交于 2019-11-27 08:22:24
I've got an assembly somewhere on the file system, e.g. "C:\temp\test.dll". In that assembly there's a ResourceDictionary, e.g. "abc.xaml". How can i get that ResourceDictionary? Maybe there is a way using Reflections? I didn't find a solution so far. Thanks in advance! Edit: Just wanted to add that I want to access the Resources in the Dictionary, e.g. a Style. You actually need to write the Uri like this: Assembly.LoadFrom(@"C:\temp\test.dll"); ResourceDictionary rd = new ResourceDictionary(); rd.Source = new Uri(@"pack://application:,,,/test;component/myresource.xaml"); Edit: I found an

Access ResourceDictionary items programmatically

泪湿孤枕 提交于 2019-11-27 08:22:21
I have a Silverlight controls assembly, called "MySilverlightControls". Several folders down into that assembly I have a class which extends a grid column from a third party vendor, let's call it "MyImageColumn.cs". I have also created a resource dictionary called Generic.xaml , this is situated in the Themes folder of the assembly. In that resource dictionary i have defined a ControlTemplate called MyImageColumnTemplate : <ControlTemplate x:Name="MyImageColumnTemplate" > <Grid Margin="8,8,4,4" MaxHeight="32" MaxWidth="32"> <Grid.Resources> <localGrid:StatusColumnImageConverter x:Key=

Load WPF styles or other Static Resources from an external file or assembly

大憨熊 提交于 2019-11-27 05:06:57
问题 I have a few WPF applications and I want all my styles to be in a shared assembly instead of declaring them in each application separately. I am looking for a way so I don't have to change all my Style="{StaticResource BlahBlah}" in the existing applications; I just want to add the reference to this style assembly, and delete it from the current application, so it's taken from the assembly. Is there any way? 回答1: Referencing an external ResourceDictionary (XAML File): <Application.Resources>

Composite WPF (Prism) module resource data templates

百般思念 提交于 2019-11-27 00:38:48
问题 Given that I have a shell application and a couple of separate module projects using Microsoft CompoisteWPF (Prism v2)... On receiving a command, a module creates a new ViewModel and adds it to a region through the region manager. var viewModel = _container.Resolve<IMyViewModel>(); _regionManager.Regions[RegionNames.ShellMainRegion].Add(viewModel); I thought that I could then create a resource dictionary within the module and set up a data template to display a view for the view model type

Trouble referencing a Resource Dictionary that contains a Merged Dictionary

只愿长相守 提交于 2019-11-26 19:52:50
I have a library, CommonLibraryWpfThemes, with several Resource Dictionary XAML files in it. My Themes/Generic.xml file contains a ResourceDictionary.MergedDictionaries declaration that merges all the other files together. Generic.xaml <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="/CommonLibraryWpfThemes;component/ResourceDictionaries/BrushDictionary.xaml" /> <ResourceDictionary Source="/CommonLibraryWpfThemes;component

Binding as a Resource

只愿长相守 提交于 2019-11-26 18:28:01
问题 Can I define a Binding as a Resource and then reuse it with different Controls properties? Example: Binding: <Window.Resources> <Binding x:Key="MyBinding" Path="MyProperty" Mode="TwoWay" /> </Window.Resources> Reuse in XAML: <TextBox Text="{StaticResource MyBinding}" /> After declaring Binding as above I got the error: "The name 'InitializeComponent' does not exist in the current context" Is there any way to reuse the same Binding in different contexts? 回答1: Direct answer to your question is