resourcedictionary

Unable to merge ResourceDictionary from a referenced project

两盒软妹~` 提交于 2019-12-03 15:52:48
I have two assemblies that each provide a common set of styles and resources that I want to include in my application. I'm using merged dictionaries in my App.xaml in order to load them, and at runtime they were just fine. Unfortunately, these resources won't load at design time, filling my Errors window with messages about unresolvable resources and giving me a UI that doesn't represent what will actually appear. This is my App.xaml as it stands right now: <Application x:Class="ClientDebug.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft

pack://application:,,,/ResourceFile.xaml Never Works

梦想与她 提交于 2019-12-03 15:32:38
I have never been able to get this format of reference a Resource Dictionary to work. What am I missing. Scenario: Creating and assembly with some usercontrols in it. At root have said file {root}/Themes/ColorThemes.xaml The ColorThemes.xaml file has its build action set to Resource . Then in in xaml file further down let say {root}/Controls/ButtonStyles/Themes/ButtonThemes.xaml (note the path is just an example) in this file I have the following bit of code: <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="pack://application:,,,/Themes/ColorThemes.xaml"/> <

Add collection or array to wpf resource dictionary

半城伤御伤魂 提交于 2019-12-03 12:47:24
问题 I've search high and low and can't find an answer to this. I have two questions How do you create an array or collection in XAML. I've got an array I want to stick in there and bind to a combo box. My first idea was to put an ItemsControl in a resource dictionary, but the ItemsSource of a combo box expects IEnumerable so that didn't work. Here's what I've tried in my resource dictionary and neither works <ItemsControl x:Key="stateList"> <sys:String>AL</sys:String> <sys:String>CA</sys:String>

Images in XAML ResourceDictionary disappear on ToolBar when Menu opens

陌路散爱 提交于 2019-12-03 12:24:02
I have started to move various common Image s into a ResourceDictionary and noticed an odd behavior in my WPF application. If the Image is used in a MenuItem and in a Button on a ToolBar , when I open the Menu the image disappears on the Button . <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <Image x:Key="NewImage" Source="/SomeApplication;component/Resources/NewDocumentHS.png" Stretch="None"/> <!-- ... --> Relevant XAML from the Window : <Menu> <MenuItem Header="_File"> <MenuItem Header="_New"

How to import one ResourceDictionary into other, in WPF?

寵の児 提交于 2019-12-03 10:46:50
Is it possible to add one resource dictionary into other one? Thanks for any help. Tilak In Dictionary2.xaml define MergedDictionaries (right after the opening ResourceDictionary tag): <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="/Path/to/Dictionary1.xaml" /> </ResourceDictionary.MergedDictionaries> there's a catch: each time you merge dictionaries you effectively create a copy of the merged dictionary. And it's recursive - if you have Dict3.xaml and Dict4.xaml that both load Dictionary2.xaml, you will have three instances of Dictionary1.xaml created The solution is a

WPF ImageSource binding with Custom converter

人走茶凉 提交于 2019-12-03 09:20:18
问题 I have a simple template for a combobox structured in this way: <ComboBox DockPanel.Dock="Left" MinWidth="100" MaxHeight="24" ItemsSource="{Binding Actions}"> <ComboBox.ItemTemplate> <DataTemplate> <StackPanel Orientation="Horizontal"> <TextBlock Text="{Binding Name}" Width="100" /> <Image Source="{Binding Converter={StaticResource TypeConverter}}" /> </StackPanel> </DataTemplate> </ComboBox.ItemTemplate> </ComboBox> So, if I use this code, everything works: <TextBlock Text="{Binding Name}"

Nested Resource Dictionary in separate library

谁都会走 提交于 2019-12-03 08:56:55
My question is very similar to this one I have a solution with a number of projects. The are two that are relevant: a class library that contains a WPF window and a project with all the WPF styles in it. Class Library with the window in Project 1 The Window's merged dictionary is something like: <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="pack://application:,,,/StyleAssembly;component/CommonStyle.xaml"/> </ResourceDictionary.MergedDictionaries> //other styles here The CommonStyle.xaml in Project 2 : <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="

How to override a global style (that doesn't have an x:Key), or alternatively apply a named style to all type-targeted controls?

为君一笑 提交于 2019-12-03 03:32:26
问题 I declared a style that I want to apply to ALL the buttons in the project, the style resides in the ResourceDictionary: <Style TargetType="StackPanel"> <Setter Property="Orientation" Value="Horizontal" /> <Setter Property="VerticalAlignment" Value="Center"/> <Setter Property="HorizontalAlignment" Value="Center"/> </Style> Now, in some window, I want to inherit from this style but add a value: <Style TargetType="StackPanel"> <Setter Property="Margin" Value="5"/> </Style> The problem is that it

Add collection or array to wpf resource dictionary

三世轮回 提交于 2019-12-03 03:14:41
I've search high and low and can't find an answer to this. I have two questions How do you create an array or collection in XAML. I've got an array I want to stick in there and bind to a combo box. My first idea was to put an ItemsControl in a resource dictionary, but the ItemsSource of a combo box expects IEnumerable so that didn't work. Here's what I've tried in my resource dictionary and neither works <ItemsControl x:Key="stateList"> <sys:String>AL</sys:String> <sys:String>CA</sys:String> <sys:String>CN</sys:String> </ItemsControl> <ItemsControl x:Key="stateList2"> <ComboBoxItem>AL<

switching wpf resource dictionaries at runtime

点点圈 提交于 2019-12-03 01:55:08
I am trying to build a wpf application that allows the user to change the theme at runtime. What I have done so far is create a resourcedictionary with all the colors for the application defined in it and then I am binding to this dictionary in the xaml. Below is the code I have for switching the resource dictionary: if (System.IO.File.Exists(fileName)) { using (FileStream fs = new FileStream(fileName, FileMode.Open)) { ResourceDictionary dic = (ResourceDictionary)XamlReader.Load(fs); Resources.MergedDictionaries.Clear(); Resources.MergedDictionaries.Add(dic); } } This code runs fine, and I