resourcedictionary

Merged ResourceDictionary vs App.xaml

◇◆丶佛笑我妖孽 提交于 2019-12-23 18:00:15
问题 I am reading up about the ResourceDictionary and have come to a confusing point. It appears I can only have 1 ResourceDictionary per XAML. So, if I wanted to use more than one, I can Merge the ResourceDictionaries. If I can merge dictionaries then where should 'global' styles live? I could have an ApplicationResourceDictionary with all the styles which are to be consistent throughout my application OR, I could save this information into the App.xaml file. both appear to be valid options but I

How can I import a deep hierarchy of merged dictionaries with 1 ResourceDictionary?

好久不见. 提交于 2019-12-23 17:04:38
问题 I am attempting to merge in dictionaries from a dependent class library project, but the resource keys can't be found. Note: I am using this Connect bug workaround from Microsoft which is supposed to allow the framework to search deep enough to find the nested resources. This does not appear to be working. Example of Failure <Application.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="/MyApplication.ControlLibrary;component

XAML - MergedDictionaries throwing XmlParseException “item has already been added”. Why?

柔情痞子 提交于 2019-12-23 09:36:56
问题 I have the following, very easy to reproduce problem: I'm creating a xaml application which uses resources from another file. The way to go is to create a MergedDictionaries-tag to merge the local and global resources, like this: <Window> <Window.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="path.to.xaml.file"/> <ResourceDictionary> <Style TargetType="{x:Type Border}" x:Key="TypeBlock"> </Style> <Style TargetType="{x:Type Border}" x:Key=

In WPF, can I share the same image resource between 2 buttons

时间秒杀一切 提交于 2019-12-23 07:40:58
问题 I want to create a On/Off button in WPF and I want it to change its appearance when the user clicks it (if it was on switch to off, if it wad off switch to on) using images. I added the images I want to use to the resources: <Window.Resources> <Image x:Key="Off1" Source="/WPFApplication;component/Images/off_button.png" Height="30" Width="70" /> <Image x:Key="On1" Source="/WPFApplication;component/Images/on_button.png" Height="30" Width="70"/> </Window.Resources> And the event code is, "flag"

C# - Getting Exception messages in English when the application is in another language?

孤街浪徒 提交于 2019-12-23 07:14:04
问题 I am trying to localize my program but I would like error messages that are sent to the developers to appear in English. I haven't been able to find a way to make this happen since it seems that if the UI culture is set to another language when an error is thrown, it is thrown in that language. Since I did not write this program myself, and it is quite large, I think it would be impractical to go create new try catch blocks to try and set the culture back to english whenever an error occurs

C# - Getting Exception messages in English when the application is in another language?

↘锁芯ラ 提交于 2019-12-23 07:11:05
问题 I am trying to localize my program but I would like error messages that are sent to the developers to appear in English. I haven't been able to find a way to make this happen since it seems that if the UI culture is set to another language when an error is thrown, it is thrown in that language. Since I did not write this program myself, and it is quite large, I think it would be impractical to go create new try catch blocks to try and set the culture back to english whenever an error occurs

Using a global ResourceDictionary in a UserControl Library

一笑奈何 提交于 2019-12-23 04:37:34
问题 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 回答1: Check out the pack URI syntax. Something like: <ResourceDictionary Source

Wpf: Passing Parameters To A ResourceDictionary

孤街浪徒 提交于 2019-12-23 03:00:49
问题 Is there a way to pass parameters to a resource dictionary? I think that I can attach a code behind for the purpose of specifying event handlers, but unfortunately, I also need to access a reference to the parent control from the event handlers. The codebehind, I believe, can be attached by specifying an x:Class attribute for the resource dictionary in xaml, and then creating a class in the same folder, the filename for which is something like [resource dictionary name].xaml.cs. The purpose

using tab and carriage return character in a WPF resource dictionary

房东的猫 提交于 2019-12-22 01:42:08
问题 How can I use tab and carriage return characters in a WPF XAML resource dictionary? This doesn't work for me: <ResourceDictionary 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" > <system:String x:Key="test_Key">Tab doesnt work\tTest\rTest</system:String> </ResourceDictionary> when I retrieve this via FindResource("test_key"), both the tab and carriage return

Using system types in XAML as resources

♀尐吖头ヾ 提交于 2019-12-22 01:27:08
问题 I have encountered a situation where it would be very useful to specify a floating point value directly in XAML and use it as a resource for several of my UI pieces. After searching around I found a good amount of information on how to include the proper assembly (mscorlib) in your XAML so you can do just that. Unfortunately, I am getting an exception in one instance where I try to do this. Here is the following XAML that recreates the situation: <Window x:Class="davidtestapp.MainWindow"