resourcedictionary

How to import one ResourceDictionary into other, in WPF?

混江龙づ霸主 提交于 2020-01-12 06:25:07
问题 Is it possible to add one resource dictionary into other one? Thanks for any help. 回答1: 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

Is there any way to use StaticResource in a WPF control library and be able to view at design-time?

≡放荡痞女 提交于 2020-01-11 21:31:09
问题 I have a WPF Control Library that is being added to a windows forms application. We want to allow the controls to be localizable, however I am not sure how to FULLY accomplish this without duplicating code. This is what I am doing now. Basically, in the windows forms app, before the main application kicks off, I am instantiating an App.xaml that live within the forms app (containing my links to my resources that also live within the forms app). This works perfectly for runtime. However, my

Wpf dynamic resource lookup for Validation.ErrorTemplate

自古美人都是妖i 提交于 2020-01-07 09:29:40
问题 in my App.xaml I defined a resource for Validation.ErrorTemplate , which depends on dynamic BorderBrush resource. I intend to define unique BorderBrush in each window I have and also within different blocks inside window. <!--validation error template--> <ControlTemplate x:Key="NonValid"> <Border BorderBrush="{DynamicResource BorderBrush}" BorderThickness="2" Margin="5"> <AdornedElementPlaceholder x:Name="ui"/> </Border> </ControlTemplate> and this one to demonstrate my problem (also with

WPF Loose XAML ResourceDictionary

与世无争的帅哥 提交于 2020-01-04 07:49:10
问题 I am trying to use a ResourceDictionary in loose XAML and load it a runtime to provide templates and styles to a WPF app. I have the XAML available in a local directory and am adding a new ResourceDictionary to App.Current.Resources.MergedDictionaries in app startup using a URI. When the XAML goes to parse, it blows up on a template where the TargetType is a custom control from the assembly that is consuming it. The specific message is: 'Failed to create a 'Type' from the text 'controls

Access ResourceDictionary by name

社会主义新天地 提交于 2020-01-02 09:09:41
问题 Lets say I have some ResourceDictionary's in my Application.xaml defined as so: <Application> <Application.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary x:Name="brushResources"/> <ResourceDictionary x:Name="graphicsResources"/> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> </Application.Resources> </Application> I would have assumed I could just simply access the dictionary in the code behind like so: brushResources

Access ResourceDictionary by name

眉间皱痕 提交于 2020-01-02 09:09:39
问题 Lets say I have some ResourceDictionary's in my Application.xaml defined as so: <Application> <Application.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary x:Name="brushResources"/> <ResourceDictionary x:Name="graphicsResources"/> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> </Application.Resources> </Application> I would have assumed I could just simply access the dictionary in the code behind like so: brushResources

Animate button background color in XAML

我怕爱的太早我们不能终老 提交于 2020-01-02 08:03:15
问题 I new to WPF and XAML, so I have ResourceDictionary (one button for now): <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <Style x:Key="ButtonProduct" TargetType="Button"> <Setter Property="SnapsToDevicePixels" Value="true"/> <Setter Property="OverridesDefaultStyle" Value="true"/> <Setter Property="HorizontalAlignment" Value="Center"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate

Animate button background color in XAML

天涯浪子 提交于 2020-01-02 08:02:37
问题 I new to WPF and XAML, so I have ResourceDictionary (one button for now): <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <Style x:Key="ButtonProduct" TargetType="Button"> <Setter Property="SnapsToDevicePixels" Value="true"/> <Setter Property="OverridesDefaultStyle" Value="true"/> <Setter Property="HorizontalAlignment" Value="Center"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate

How to implement theming in wpf

回眸只為那壹抹淺笑 提交于 2019-12-30 23:52:12
问题 I want to implement ASP.Net type theme in WPF. User have selection of various predefined themes and can switch to another theme. To implement this I have tried by creating different resourcedictionary for each theme and store required style with key. The collection of keys are same in all themes but its definition is different in each. I am using below code to switch theme on click: var theme = Application.LoadComponent(uri) as ResourceDictionary; Application.Current.Resources

tag does not exist in XML namespace

回眸只為那壹抹淺笑 提交于 2019-12-30 05:40:06
问题 This error seems to be posted all over the place but each one seems to have its own solution, none of which solved my problem. I am getting an error for a Resource Dictionary I am making (and later merging) that the tag 'ModelBindings' does not exist in XML namespace 'clr-namespace:Company.Project.Module.Folder;assembly=Company.Project.Module' The assembly I am referencing is custom and contained within the solution. Not only that but we have looked at the dll put into the bin for the project