resourcedictionary

Using BasedOn property with a Style defined in a different dictionary

走远了吗. 提交于 2019-12-04 10:45:59
The application I'm working on has 2 ResourceDictionary, DefaultStyles.xaml and CustomStyles.xaml. Is it possible that a style in the CustomStyles dictionary uses a base style defined in the other dictionary? DefaultStyles.xaml: <Style x:Key="TextBlockDefaultStyle" TargetType="TextBlock"> <Setter Property="Margin" Value="4" /> </Style> CustomStyles.xaml: <Style x:Key="SectionTitleStyle" TargetType="TextBlock" BasedOn="{StaticResource TextBlockDefaultStyle}"> <Setter Property="FontSize" Value="16" /> </Style> App.xaml: <Application.Resources> <ResourceDictionary> <ResourceDictionary

WPF: Sharing resources across assemblies

南笙酒味 提交于 2019-12-04 06:44:01
问题 I previously posted a question on sharing resources across assemblies using Themes/generic.xaml and the ComponentResourceKey markup extension. The solution works nicely, but it requres all of the shared resources to be located in the generic.xaml resource dictionary. Mine is getting rather large, so I thought I would use merged dictionaries in generic.xaml to organize things. I have had no luck so far. I ran some tests using the demo from my previous post, and as soon as I move resources to a

System.Drawing.Image from ImageSource in Resources

好久不见. 提交于 2019-12-04 06:39:35
问题 My question is very similar to this one: wpf image resources and changing image in wpf control at runtime, but with a slight twist. Here is my ResourceDictionary.xaml: <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <ImageSource x:Key="DisconnectedIcon">Images/disconnect.png</ImageSource> <ImageSource x:Key="Synced">Images/tick.png</ImageSource> <ImageSource x:Key="NotSynced">Images/x.png<

xClassNotDerivedFromElement error when adding Code Behind to Resource Dictionary in silverlight

こ雲淡風輕ζ 提交于 2019-12-04 03:33:25
I need to add code behind class to Resource Dictionary as described in this question . (I know that this is not a good practise but it should work based on the comments for linked question) .I'm referencing the code with x:Class attribute: XAML (separate Resource Dictionary file): <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Class="MyNamespace.MyStandardResources"> ... </ResourceDictionary> CODE: using System.Windows; namespace MyNamespace { public partial class MyStandardResources :

Why are absolute uri's required for merged dictionaries in Generic.xaml?

寵の児 提交于 2019-12-04 02:02:30
Consider a File | New Project of a WPF Application that contains: A new custom control named CustomControl1 Two new resource dictionaries named Dictionary1 and Dictionary2 Take the generated style out of Generic.xaml and move it to Dictionary2. Then merge Dictionary2 into Dictionary1 and Dictionary1 into Generic like this: <!--Generic.xaml--> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="pack://application:,,,/Themes/Dictionary1.xaml"/> </ResourceDictionary.MergedDictionaries> <!--Dictionary1.xaml--> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source=

How can I add a Path, that has been defined in the XAML ResourceDictionary, multiple times to a WPF form at runtime?

泪湿孤枕 提交于 2019-12-04 01:50:25
I have a defined path in XAML: <UserControl.Resources> <ResourceDictionary> <Path x:Key="N44" Width="20" Height="80" Stretch="Fill" Fill="#FF000000" Data="M 20,25.2941L 20,29.4118L 15.9091,29.4118L 15.9091,40L 12.2727,40L 12.2727,29.4118L 2.54313e-006,29.4118L 2.54313e-006,25.6985L 13.4872,7.62939e-006L 15.9091,7.62939e-006L 15.9091,25.2941L 20,25.2941 Z M 12.2727,25.2941L 12.2727,5.28493L 2.09517,25.2941L 12.2727,25.2941 Z M 20,65.2941L 20,69.4118L 15.9091,69.4118L 15.9091,80L 12.2727,80L 12.2727,69.4118L -5.08626e-006,69.4118L -5.08626e-006,65.6985L 13.4872,40L 15.9091,40L 15.9091,65.2941L

What is the scope of StaticResource within a WPF ResourceDictionary?

左心房为你撑大大i 提交于 2019-12-04 01:04:51
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 ) <BooleanToVisibilityConverter x:Key="BoolToVis" /> When I start my app up - I get the following XamlParseException:

accessing a resource dictionary in code wpf

元气小坏坏 提交于 2019-12-03 23:08:09
The same line of code in the same assembly works for one test fixture but not another. Here is the line of code: var dic = new ResourceDictionary { Source = new Uri("pack://application:,,,/MyApp.Wpf;component/ImageResources.xaml") }; The error I get in the other test fixture is System.UriFormatException : Invalid URI: Invalid port specified. The uri string also works in xaml. Is there a better way to load a resource dictionary in code? Cheers, Berryl === UPDATE === As I found in this posting , an Invalid port was occurring because the pack scheme wasn't registered, which can be done with code

Vs2017: An Error Occured while finding the resource dictionary

…衆ロ難τιáo~ 提交于 2019-12-03 17:16:50
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/test.xaml"/> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> </Application.Resources>

Referencing a resource in a ResourceDictionary from a different ResourceDictionary in Silverlight

半腔热情 提交于 2019-12-03 16:24:44
问题 I have the following set of code in my App.xaml: <Application.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="/Client.Common;component/Theme/Brushes.xaml"/> <ResourceDictionary Source="/Client.Common;component/Theme/Fonts.xaml"/> <ResourceDictionary Source="/Client.Common;component/Theme/CoreStyles.xaml"/> <ResourceDictionary Source="/Client.Common;component/Theme/SdkStyles.xaml"/> <ResourceDictionary Source="/Client.Common;component/Theme