resourcedictionary

Accessing ResourceDictionary from WPF UserControl

落花浮王杯 提交于 2019-12-01 16:38:37
I'm trying to access a resource dictionary in a UserControl code-behind via C# and I'm having little success. Merged Dictionary: <UserControl.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="/Resources/BiometricDictionary.xaml" /> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> </UserControl.Resources> Embedded Dictionary: <UserControl.Resources> <BitmapImage x:Key="imageDefault">/Resources/Images/default_thumb.png</BitmapImage> <BitmapImage x:Key="imageDisconnected">/Resources/Images/disconnect_thumb.png</BitmapImage>

Accessing ResourceDictionary from WPF UserControl

∥☆過路亽.° 提交于 2019-12-01 15:57:43
问题 I'm trying to access a resource dictionary in a UserControl code-behind via C# and I'm having little success. Merged Dictionary: <UserControl.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="/Resources/BiometricDictionary.xaml" /> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> </UserControl.Resources> Embedded Dictionary: <UserControl.Resources> <BitmapImage x:Key="imageDefault">/Resources/Images/default_thumb.png</BitmapImage

WPF VS2013: An error occurred while finding the resource dictionary

微笑、不失礼 提交于 2019-12-01 06:41:09
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. It should read: ...Source="/Skins/MainSkin.xaml" As the skin isn't in the Content directory. At the moment it's looking for Content/Skins/MainSkin.xaml (hence / will 'take it up' a directory back to the root). 来源: https:

Shared project with resource dictionary (xaml)

帅比萌擦擦* 提交于 2019-12-01 06:26:56
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 'System.IO.IOException' occurred in PresentationFramework.dll but was not handled in user code Additional

Merged dictionaries and local resources

依然范特西╮ 提交于 2019-12-01 00:14:22
问题 I have a Styles.xaml that groups many ResourceDictionary s inside a MergedDictionary . I imported Styles.xaml in my UserControl.Resources <UserControl.Resources> <ResourceDictionary Source="Dictionaries\Styles.xaml" /> </UserControl.Resources> but when I try to add a converter <UserControl.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="Dictionaries\Styles.xaml" /> <--! Exception --> </ResourceDictionary.MergedDictionaries>

winrt xaml merged resources

馋奶兔 提交于 2019-11-30 23:46:59
I need to separate application styles to several xaml files. But I also need to define some shared values like <x:Double x:Key="SharedValue">100</x:Double> in single file for use this value in styles defined in other files. For instance: <Style x:Name="SomeStyle" TargetType="TextBox"> <Setter Property="Width" Value="{StaticResource SharedValue}"/> </Style> and in another resource dictionary file: <Style x:Name="AnotherStyle" TargetType="Button"> <Setter Property="Height" Value="{StaticResource SharedValue}"/> </Style> But when I try to define merged resource dictionary in App.xaml file

winrt xaml merged resources

你离开我真会死。 提交于 2019-11-30 18:04:33
问题 I need to separate application styles to several xaml files. But I also need to define some shared values like <x:Double x:Key="SharedValue">100</x:Double> in single file for use this value in styles defined in other files. For instance: <Style x:Name="SomeStyle" TargetType="TextBox"> <Setter Property="Width" Value="{StaticResource SharedValue}"/> </Style> and in another resource dictionary file: <Style x:Name="AnotherStyle" TargetType="Button"> <Setter Property="Height" Value="

WPF Using multiple Resource Dictionaries from multiple projects

对着背影说爱祢 提交于 2019-11-30 17:02:25
I have two class Library projects: Project A.Themes Project B.Themes Project A.Themes is my base Themes Project. Project B.Themes using A.Themes and have new styles and some of the resources have keys that already defined in A.Themes. We want to use this two themes in our Project, and if we use a resource that is defined in both of the project we want to take the resource from B.Themes. This is our code: A.Themes have few files of styles: Brushes.xaml Buttons.xaml CheckBox.xaml etc.. we load them in Bundle.Xaml: <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="pack:/

Memory leak when using SharedResourceDictionary

懵懂的女人 提交于 2019-11-30 11:37:29
问题 if you worked on some larger wpf applications you might be familiar with this. Because ResourceDictionaries are always instantiated, everytime they are found in an XAML we might end up having one resource dictionary multiple times in memory. So the above mentioned solution seems like a very good alternative. In fact for our current project this trick did a lot ... Memory consumption from 800mb down to 44mb, which is a really huge impact. Unfortunately this solution comes at a cost, which i

WPF: Style based on another one in a separate assembly

浪子不回头ぞ 提交于 2019-11-30 08:26:01
Assembly A - ResourceDictionary contains StyleA style. Assembly B - ResourceDictionary.MergedDictionaries to merge resources from Assembly A into B. I would like to create a style in Assembly B "based on" StyleA. Is it possible? I am trying to create this style: <Style x:Key="StyleB" BasedOn="{StaticResource StyleA}"> <Setter Property="Button.Foreground" Value="Khaki"/> </Style> But I get a XamlParseException exception at run-time, if I use StyleB: Cannot convert the value in attribute 'Style' to object of type 'System.Windows.Style'. Can only base on a Style with target type that is base type