resourcedictionary

Using BasedOn property with a Style defined in a different dictionary

╄→尐↘猪︶ㄣ 提交于 2019-12-06 04:23:29
问题 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=

using viewbox in ResourceDictionary file

半城伤御伤魂 提交于 2019-12-06 03:34:06
i have ResourceFile1.xaml file its content <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <Viewbox x:Key="Flash-On" > <Grid Width="256" Height="256" Visibility="Visible"> <Path Tag="Icon" Data="F1M376.251,632.755L385.665,632.755 381.302,646.07 394.618,646.07 389.11,660.302 393.01,660.302 381.531,672.93 377.398,660.763 381.073,660.763 383.829,652.268 369.825,652.268 376.251,632.755z" Stretch="Uniform" Fill="#FFFFFFFF" Width="176" Height="176" Margin="0,0,0,0" RenderTransformOrigin="0.5,0.5"> <Path

ResourceDictionary Source Binding to Module (for Localization)

元气小坏坏 提交于 2019-12-05 23:47:31
I have a XAML Window that has a set of strings that are bound to objects like so: <Label Content="{StaticResource LabelUserName}" HorizontalAlignment="Right" Name="Label1" VerticalAlignment="Center" /> This code works fine when I define my ResouceDictionary like this: <Window.Resources> <ResourceDictionary > <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="/Strings/Strings_en-US.xaml" /> </ResourceDictionary.MergedDictionaries> <ObjectDataProvider x:Key="objLogon" ObjectType="{x:Type StarUtilities:Logon}" /> </ResourceDictionary> </Window.Resources> However, I want to beable

xClassNotDerivedFromElement error when adding Code Behind to Resource Dictionary in silverlight

强颜欢笑 提交于 2019-12-05 21:34:43
问题 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:

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

懵懂的女人 提交于 2019-12-05 16:22:38
问题 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

Adding a static ResourceDictionary to UserControls before the XAML is parsed

可紊 提交于 2019-12-05 14:16:37
I have one WPF control that I want to use in my WinForms application (using an ElementHost) in several places (=> multiple instances of this control). Furthermore I want all instances of my UserControl to share one single Instance of a ResourceDictionary. In WPF applications I would achieve that by merging my ResourceDictionary in the Application Resources. However, I don't want to create an WPF Application Instance in my WinForms application. Instead I am looking for another way. I found one solution but I am hoping you know a better way that does not require any code behind: public static

Runtime theme switching with explicit styles in Silverlight 4

倖福魔咒の 提交于 2019-12-05 13:38:44
It's been requested that we add dynamic theme switching to our application, and I'm having problems figuring out how to do this. Here's the current situation: our application has a merged resource dictionary with explicit (not implicit) styles. The views in our application refer to these styles through the StaticResource markup extension. The reason why we're not using implicit styles is that we have multiple looks for common types of controls; for example, buttons in one location look different than buttons in another. So what we are wanting to do is create themes that replace these named

Style inheritance based on different XAML

我与影子孤独终老i 提交于 2019-12-05 13:24:17
问题 How to specify BasedOn tag in a style to a style defined in some other file. Example, Dictionary1.xaml defines <Style x:Key="basicStyle" TargetType="TextBlock" > <Setter Property="FontSize" Value="24"></Setter> <Setter Property="Foreground" Value="DarkGray"></Setter> <Setter Property="FontWeight" Value="Bold"></Setter> </Style> In Dictionary2.xaml i need something like <Style x:Key="headerStyle" TargetType="TextBlock" > <Setter Property="FontSize" Value="46"></Setter> <Setter Property=

accessing a resource dictionary in code wpf

微笑、不失礼 提交于 2019-12-05 11:09:31
问题 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,

Merged ResourceDictionary initalization in UWP app

和自甴很熟 提交于 2019-12-05 08:27:05
During development of my UWP app I have noticed and intersting oddity which I have hard time explaining. I user MvvmLight and I decided to add the ViewModelLocator resource instance in a separate ResourceDictionary Core.xaml which will be referenced from MergedDictionaries in App.xaml . Following is the content of App.xaml : <Application ...> <Application.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="Resources/Core.xaml" /> <ResourceDictionary Source="Resources/Converters.xaml" /> </ResourceDictionary.MergedDictionaries> <