resourcedictionary

How to change UI language using resource dictionary at run time?

倾然丶 夕夏残阳落幕 提交于 2019-12-08 05:14:02
问题 I want to change my project language by button_click event, so I use ResourceDictionary to do it like this: XAML <Button Content="{DynamicResource LanguageSetting}" Click="btn_LanguageSetting_Click"/> Code Behind public static string windowCurrentLanguageFile = "Language/en.xaml"; private void btn_LanguageSetting_Click(object sender, RoutedEventArgs e) { windowCurrentLanguageFile = windowCurrentLanguageFile == "Language/en.xaml" ? "Language/fr.xaml" : "Language/en.xaml"; var rd = new

Wpf: Passing Parameters To A ResourceDictionary

我的未来我决定 提交于 2019-12-08 05:01:29
Is there a way to pass parameters to a resource dictionary? I think that I can attach a code behind for the purpose of specifying event handlers, but unfortunately, I also need to access a reference to the parent control from the event handlers. The codebehind, I believe, can be attached by specifying an x:Class attribute for the resource dictionary in xaml, and then creating a class in the same folder, the filename for which is something like [resource dictionary name].xaml.cs. The purpose is to seperate the code for four hierarchical data templates that I'm using in a single treeview control

How to change ResourceDictionary Dynamically

爷,独闯天下 提交于 2019-12-07 22:49:56
问题 I need to change ResourceDictionary in App.xaml file dynamically. I have tried the following code: ResourceDictionary newRes = new ResourceDictionary(); newRes.Source = new Uri("/PsyboInventory;component/TitleBarResource.xaml", UriKind.RelativeOrAbsolute); this.Resources.MergedDictionaries.Clear(); this.Resources.MergedDictionaries.Add(newRes); There is no error, but the theme not change 回答1: In button click you can write this code var app = (App)Application.Current; app.ChangeTheme(new Uri(

using viewbox in ResourceDictionary file

佐手、 提交于 2019-12-07 19:25:16
问题 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

How to add PresentationFramework.Aero theme to ResourceDictionary

北慕城南 提交于 2019-12-07 19:09:28
问题 I want to add the PresentationFramework.Aero theme to my ResourceDictionary. The ResourceDictionary itself is in one assembly called ProjectResources. Within this assembly I define all my styles for my project. So this ResourceDictionary is used by several different assemblies in my project. So far it worked fine for all my Dictionaries defined. Now i want to add the Aero theme. But I always get the exception: An unhandled exception of type 'System.Windows.Markup.XamlParseException' occurred

Runtime theme switching with explicit styles in Silverlight 4

↘锁芯ラ 提交于 2019-12-07 08:02:41
问题 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

Adding a static ResourceDictionary to UserControls before the XAML is parsed

妖精的绣舞 提交于 2019-12-07 06:59:42
问题 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

Merged ResourceDictionary initalization in UWP app

孤街醉人 提交于 2019-12-07 06:54:57
问题 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" />

How to add ResourceDictionary in Phone class library project and access it

自作多情 提交于 2019-12-07 05:36:22
问题 I am working on a project where i have child project which is referencing the library project. In my Library project(Phone class library) how do i create ResourceDictionary.xaml where i need to add some styles and use it in xaml files and as well as .cs files. I need to access styles in ResourceDictionary.xaml in my xaml files as well as .cs files how to do it ? 回答1: Create a folder as Generic in the root folder and have your resource files there... To access it in XAML <ResourceDictionary

Insert a WPF Resource Dictionary into a class library via Visual Studio 2010

早过忘川 提交于 2019-12-07 03:14:39
问题 I have a class library and want to change the type so that I also can add a WPF resource dictionaries. I have added the WPF references and also tried to sync the AssemblyInfo.cs file with a project that allows the addition of such resource files, however without success. If I use the add-new-dialog from Visual Studio, the template for WPF resource dictionaries is not available - If I create the file manually and then reference it, all works fine. How can I change my project to a WPF custom