resourcedictionary

Design-time Error finding the Resource Dictionary - Inconsistent between projects

喜欢而已 提交于 2021-02-18 21:09:50
问题 TLDR; Screens newly referencing an external ResourceDictionary file in VS2015 style correctly at run-time, but not at design-time. What gives? At work, we have a WinForms product which houses many WinForms screens with one developer actively adding new ones, as well as a handful of WPF screens with me adding new ones. Noticing a lot repetitious code/styling in existing WPF screens, I created a single project to house this - to be referenced by all existing/future WPF screens. Project:

Design-time Error finding the Resource Dictionary - Inconsistent between projects

浪子不回头ぞ 提交于 2021-02-18 21:02:42
问题 TLDR; Screens newly referencing an external ResourceDictionary file in VS2015 style correctly at run-time, but not at design-time. What gives? At work, we have a WinForms product which houses many WinForms screens with one developer actively adding new ones, as well as a handful of WPF screens with me adding new ones. Noticing a lot repetitious code/styling in existing WPF screens, I created a single project to house this - to be referenced by all existing/future WPF screens. Project:

Design-time Error finding the Resource Dictionary - Inconsistent between projects

旧城冷巷雨未停 提交于 2021-02-18 20:59:16
问题 TLDR; Screens newly referencing an external ResourceDictionary file in VS2015 style correctly at run-time, but not at design-time. What gives? At work, we have a WinForms product which houses many WinForms screens with one developer actively adding new ones, as well as a handful of WPF screens with me adding new ones. Noticing a lot repetitious code/styling in existing WPF screens, I created a single project to house this - to be referenced by all existing/future WPF screens. Project:

Change FontSize in App resource from code behind

☆樱花仙子☆ 提交于 2021-02-05 08:12:09
问题 For a WPF TextBox control, I set the FontSize using a XAML style in my app.xaml like this: <System:Double x:Key="FontSizeVal">12</System:Double> <Style TargetType="{x:Type TextBlock}"> <Setter Property="FontSize" Value="{DynamicResource FontSizeVal}"/> </Style> I want change FontSizeVal from Code Behind instead. I tried to use the below code, but it did not work (System.InvalidCastException: 'Specified cast is not valid.'): App.Current.Resources["FontSizeVal"] = 10; How can I set the

How to remove App.xaml ResourceDictionary at startup?

大兔子大兔子 提交于 2021-01-27 16:24:05
问题 I have a ResourceDictionary declared in the App.xaml file as below: <Application.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="Skins/DefaultSkin.xaml"/> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> </Application.Resources> The problem is that when I attempt to load a different skin at start-up (using the App.xaml.cs constructor to load the last used ResourceDictionary skin) I find that the ResourceDictionary set in

xaml ResourceDictionary inside User Control Library

你离开我真会死。 提交于 2020-02-23 03:43:06
问题 how is it possible to define a ResourceDictionary inside a User Control Library and access them via Xaml-Code. I've created something like this: <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro" xmlns:Dialog="clr-namespace:MahApps.Metro.Controls.Dialogs;assembly=MahApps.Metro" > <Style x:Key="NormalStyle" TargetType="{x:Type

App runs normally but has “errors” during design time: “does not exist in namespace” and “an error occured when finding the resource dictionary”

限于喜欢 提交于 2020-01-25 23:56:11
问题 My application has certain errors, in its error box during design time, to do with it's resource dictionary. For example, in my Main Window a resource dictionary is called as follows; <Window.Resources> <ResourceDictionary Source="Resources.xaml"/> </Window.Resources> I get a blueline on the middle line saying "An error has occurred while finding the resource dictionary "Resources.xaml". Yet, the Resources.xaml is in the root folder of the project, and so is the MainWindow. I am aware that

How to reuse layouts in WPF

。_饼干妹妹 提交于 2020-01-23 05:50:08
问题 I'm trying to create a application that will be tabbed where each tab will have a button area and a view area. Now each tab will essentially have the same layout just different things in the layout and I wanted to be able to reuse the same layout so that I won't have to change at many places ( it's just not good programming ). Can I accomplish this using resources or perhaps Styles. Please supply a light code example if possible. EDIT: I've decided to add an example of what I'm trying to do

XAML editor complains “Object does not match target type” for SharedResourceDictionary.Source

北慕城南 提交于 2020-01-14 09:39:06
问题 We use SharedResourceDictionary in our project. The dictionary is constructed from several posts here on SO. But I have reduced it to this: public class SharedResourceDictionary : ResourceDictionary { public new Uri Source { get { return base.Source; } set { base.Source = value; } } } In new VS2015 the XAML designed cannot load the styles and complains 1. The resource "..." could not be resolved. 2. Object does not match target type. 3. The resource "..." could not be resolved. 4. The

Difference between approches for setting DefaultStyleKey

南楼画角 提交于 2020-01-14 08:48:29
问题 I am creating a custom control(deriving from Control ) and want to define a default theme for the control. Previously all the custom controls I created, I have used static IntegerUpDown() { DefaultStyleKeyProperty.OverrideMetadata(typeof(IntegerUpDown), new FrameworkPropertyMetadata(typeof(IntegerUpDown))); } with this assembly attribute: [assembly: ThemeInfo(ResourceDictionaryLocation.SourceAssembly, ResourceDictionaryLocation.SourceAssembly)] Alternative approach to do this is (which I have