resourcedictionary

What is the scope of StaticResource within a WPF ResourceDictionary?

那年仲夏 提交于 2019-12-21 07:34:08
问题 I have a WPF ResourceDictionary with the following TextBlock: <TextBlock Visibility="{Binding Converter={StaticResource MyBoolProp ResourceKey=BoolToVis}}"> </TextBlock> The ResourceDictionary is included in App.xaml under MergedDictionaries: <Application.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="MyResourceDictionary.xaml"/> Within the App.xaml I have defined the BoolToVis converter (again, under Application.Resources )

Vs2017: An Error Occured while finding the resource dictionary

余生颓废 提交于 2019-12-21 05:39:04
问题 Am getting the below error when i tried to refer the resource dictionary my app.xaml file <Application x:Class="DesignerPoc.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:DesignerPoc" StartupUri="MainWindow.xaml"> <Application.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="pack://application:,,,/Dashboard.Designer.WPF;Connection/Views

Adding a static object to a resource dictionary

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-21 03:37:35
问题 I have a class which is referenced in multiple views, but I would like there to be only one instance of the class shared among them. I have implemented my class like so: using System; public class Singleton { private static Singleton instance; private Singleton() {} public static Singleton Instance { get { if (instance == null) { instance = new Singleton(); } return instance; } } } Is there a way I can add Singleton.Instance to my resource dictionary as a resource? I would like to write

switching wpf resource dictionaries at runtime

a 夏天 提交于 2019-12-20 11:52:57
问题 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);

switching wpf resource dictionaries at runtime

那年仲夏 提交于 2019-12-20 11:52:43
问题 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);

Call events or methods located in a Class from XAML

房东的猫 提交于 2019-12-20 05:19:06
问题 Hi i am trying if it's possible having an Event like TextChanged (of a TextBox) located in another place independent of the Window CodeBehind (like a Class). What i am trying to do is having in the ResourceDictionary a reference to an event of the TextBox. (Because the ResourcesDictionaries doesn't have a CodeBehind.) Note: It really have to be by this way, because i am customizing another control to have some TextBoxes dynamically and all the TextBoxes will fire the same event when

searching and listing WPF resource dictionaries in a folder

主宰稳场 提交于 2019-12-19 20:48:34
问题 I'm making a WPF application that is going to have multiple skins branded in by our build system. Ideally we would like the application to list off the skins available as some builds will have one to many skins. At runtime is there a way to enumerate all the Resource Dictionaries in a specific folder? I want to avoid hard coding the XAML filenames in my codebehind as this is a changing situation. 回答1: Sort of. You can enumerate all BAML (compiled XAML) files as follows: var resourcesName =

Set a ResourceDictionary DataContext from code behind

笑着哭i 提交于 2019-12-19 10:14:24
问题 I'm trying to set a ResourceDictionary DataContext, from the code behind of my Resource Dictionary. I have a Data Template that uses its own style (the Resource Dictionary), the style contains a checkbox with its own style : <Style x:Key="CheckBoxStyle" TargetType="CheckBox"> <EventSetter Event="CheckBox.Checked" Handler="CheckBox_Checked"/> <EventSetter Event="CheckBox.Unchecked" Handler="CheckBox_Unchecked"/> </Style> In the CheckBox_Checked event, I want to reference the dictionary's

WPF VS2013: An error occurred while finding the resource dictionary

℡╲_俬逩灬. 提交于 2019-12-19 09:05:32
问题 Team, I have a simple wpf project in Visual Studio 2013. The structure is shown below. All that the error says is as shown in the title "An error occurred while finding the resource dictionary". I have tried many suggestions from the net and running out of patience. Every thing seems to be alright. Any one experienced with this can kindly suggest some thing. Thanks in advance. 回答1: It should read: ...Source="/Skins/MainSkin.xaml" As the skin isn't in the Content directory. At the moment it's

Shared project with resource dictionary (xaml)

六眼飞鱼酱① 提交于 2019-12-19 08:54:32
问题 I am looking for a way to share ResourceDictionary between projects. Adding new item to shared project doesn't offer resource dictionary. It can be created in other (main) project and dragged. But then I can't change its build options to Page : The idea is to load resource dictionary like this var dictionary = new ResourceDictionary(); dictionary.Source = new Uri("/WpfApplication91;component/Dictionary2.xaml", UriKind.Relative); This is obviously fails currently with An exception of type