resourcedictionary

Alias or Reference in ResourceDictionary

柔情痞子 提交于 2019-12-29 09:09:32
问题 I'm looking for a way to essentially give an item in a ResourceDictionary multiple keys. Is there a way to do this? <DataTemplate x:Key="myTemplate" ... /> <AliasedResource x:Key="myTemplateViaAlias" Target="myTemplate" OR_Target={StaticResource myTemplate} /> When I call TryFindResource("myTemplateViaAlias") I want to get myTemplate out. I suppose I could create an AliasedResource class myself and dereference it in code when I get it out of the dictionary, but I'd rather not do that if there

Binding properties through DataTemplates and ContentControl

故事扮演 提交于 2019-12-29 08:26:06
问题 I liked this answer, and it almost fit me. But, how can I achieve this if my DataTemplate is in a external ResourceDictionary ? I'm using Prism and I provide the DataTemplates (for generic CRUD views) by each module, by using files like this: <ResourceDictionary ... some hidden ns here ... > <DataTemplate DataType="{x:Type model:Operation}"> <vw:OperationView /> </DataTemplate> <DataTemplate DataType="{x:Type model:Customer}"> <vw:CustomerView /> </DataTemplate> </ResourceDictionary> Then I

Is it possible to share a ResourceDictionary file between multiple projects?

喜欢而已 提交于 2019-12-29 06:40:12
问题 If I have a ResourceDictionary in one project, is it possible to create another project that uses resources defined in the first project? Note that both projects are WPF Applications, not ControlLibraries. Thanks!! 回答1: Yes, of course that's possible, as long as Project B has a reference to Project A. <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="/Project A;component/YourSubFolder/YourResourceFile.xaml" /> </ResourceDictionary.MergedDictionaries> Then you can just use

MergedDictionaries and Resource lookup

痴心易碎 提交于 2019-12-28 05:14:14
问题 i have a problem with Resource dictionaries and mergeddictionaries in general, especially when it comes to resource-lookup performance. After some performance testing i found that ResourceDictionary.get_MergedDictionaries is the call with the most hits (checked in ANTS profiler). We have around ~300 resource dictionary xamls, and a lot of them are using merged dictionary to "include" other styles. Well the get_MergedDictionaries count on one part of our application, where not much is

WP7 Converter in ResourceDictionary

吃可爱长大的小学妹 提交于 2019-12-25 18:56:16
问题 On the page we declare a converter as <phone:PhoneApplicationPage.Resources> <local:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter"/> </phone:PhoneApplicationPage.Resources> How to declare it in ResourceDictionary? 回答1: How to declare it in ResourceDictionary? <local:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter"/> 回答2: Add this in App.xaml <Application.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary>

Accessing DataTemplate from ResourceDictionary in code behind

[亡魂溺海] 提交于 2019-12-25 09:00:45
问题 I am trying to convert a vendor provided VB solution to C# . I need to load a DataTemplate from a custom ResourceDictionary XAML into a c# class. I cannot determine how to get the DataTemplate. I am able to create a ResourceDictionary and load the XAML but am stumped from there. Here is my XAML [EditorResources]. <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:PropertyEditing="clr-namespace

Trace WPF System.Windows.ResourceDictionary warning Resource not found

て烟熏妆下的殇ゞ 提交于 2019-12-25 08:47:32
问题 I get below error on output window. I can't find what is the problem? System.Windows.ResourceDictionary Warning: 9 : Resource not found; ResourceKey='17' System.Windows.ResourceDictionary Warning: 9 : Resource not found; ResourceKey='#FF000000'; ResourceKey.HashCode='51639504'; ResourceKey.Type='System.Windows.Media.SolidColorBrush' System.Windows.ResourceDictionary Warning: 9 : Resource not found; ResourceKey='17' System.Windows.ResourceDictionary Warning: 9 : Resource not found; ResourceKey

How can code find resource in model that does not have access to user control

空扰寡人 提交于 2019-12-25 02:50:11
问题 I have a UserControl that has MergedDictionaries : <UserControl.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="../LimitResources.xaml" /> <ResourceDictionary Source="../MenuItemTemplateResources.xaml" /> </ResourceDictionary.MergedDictionaries> ... </UserControl.Resources> in my Model a Menu is created. I want to access ControlTemplate declared in MenuItemTemplateResources.xaml. The ControlTemplate looks like this <ControlTemplate x:Key=

Creating WPF ResourceDictionary from code doesn't seem to work when setting ResourceDictionary.Source

眉间皱痕 提交于 2019-12-24 06:39:12
问题 I have a project containing a xaml ResourceDictionary that I wish to use outside of a FrameworkElement. The resource dictionary will contain a DataTemplate for a class local to the project to avoid polluting the app.xaml (as the project is a prism module, and will not always be present depending on config). So, I have a test.xaml file with a Resource build action. This is intended to supply the DataTemplate for a TestObject class. In the TestObject class I have a GetTemplate() method The

Add a WPF XAML resourcedictionary to a DLL

被刻印的时光 ゝ 提交于 2019-12-24 04:17:30
问题 Maybe I'm misunderstanding how this all works and you can't really stuff plain old XAML files into a DLL as data which can be grabbed out later - but I thought this was possible. I have tried over and over and over again for like five hours to get this to work so I'm finally asking Stack Overflow. I have a XAML file in a WPF User Control Library project. In a perfect world, I should be able to have this XAML file embedded in some way into the DLL for reference in another project. I don't want