resourcedictionary

Error finding merged resource dictionary in another assembly

可紊 提交于 2019-11-29 22:12:12
问题 I'm really beating my head against the wall here. First, some background. The app is a PRISM 4/MVVM app using WPF and my solution is structured as follows: MyCompany.MyProduct (MyCompany.MyProduct.exe) +-- Shell.xaml Shell.xaml.cs app.config (etc) MyCompany.MyProduct.Infrastructure (MyCompany.MyProduct.Infrastructure.dll) +-- Resources | +-- MyApplicationStyles.xaml | SuperCoolImage.png | (etc) +-- BaseClasses +-- ViewModelBase.cs (etc) MyCompany.MyProduct.Modules.ModuleA (MyCompany.MyProduct

Setting WindowStartupLocation from ResourceDictionary throws XamlParseException

喜夏-厌秋 提交于 2019-11-29 13:42:31
When I attempt to set the WindowStartupLocation property through a Setter within a ResourceDictionary , I get a XamlParseException : 'Set property 'System.Windows.Setter.Property' threw an exception.' Line number 'x' and line position 'y'. The inner exception is an ArgumentNullException : Value cannot be null. Parameter name: property. My style within the resource dictionary is: <Style TargetType="Window" x:Key="WindowStyle"> <Setter Property="SizeToContent" Value="WidthAndHeight" /> <Setter Property="ResizeMode" Value="CanMinimize" /> <Setter Property="WindowStartupLocation" Value=

Error when using StaticResourceExtension inside Style.Resources

早过忘川 提交于 2019-11-29 13:03:45
I am using DynamicResource in a template, and StaticResourceExtensions as resource inside each style using that template, so that the DynamicResource is evaluated differently in each of them them. The problem is, I get this error: Unable to cast object of type 'System.Windows.Media.Effects.DropShadowEffect' to type 'System.Windows.ResourceDictionary' Here's my code: <DropShadowEffect x:Key="Sombra" Opacity="0.5" ShadowDepth="3" BlurRadius="5" /> <ControlTemplate x:Key="ControleGeometriaTemplate" TargetType="{x:Type Control}" > <Border x:Name="border" Background="{TemplateBinding Background}"

WPF: Style based on another one in a separate assembly

蓝咒 提交于 2019-11-29 11:14:44
问题 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

Split one big XAML in number of Sub-XAML files

£可爱£侵袭症+ 提交于 2019-11-29 06:02:13
问题 In my WPF4 Desktop-based application there is a big block with sidebar menu that repeats in each window and takes about 70 lines of XAML. In order to improve code reuse, I would like to split XAML file in two files: XAML-file that contains code for sidebar menu (≈70 lines) Base XAML file that contains «include/reference» to XAML-file with sidebar menu code As I understood, there are two ways to implement my problem: Use ResourceDictionary Use UserControl / CustomControl My questions are: What

Is it possible to share a ResourceDictionary file between multiple projects?

江枫思渺然 提交于 2019-11-29 05:36:10
If I have a ResourceDictionary in one project, is it possible to create another project that uses resources defined in the first project? Note that both projects are WPF Applications, not ControlLibraries. Thanks!! user112889 Yes, of course that's possible, as long as Project B has a reference to Project A. <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="/Project A;component/YourSubFolder/YourResourceFile.xaml" /> </ResourceDictionary.MergedDictionaries> Then you can just use the Resources defined in YourResourceFile.xaml. David Dowdle I found that I had to reference the

WPF doesn't apply style to first element

ぃ、小莉子 提交于 2019-11-29 05:29:18
问题 I have a simple WPF window that has 12 buttons on it. I want the same style to be applied to all of them. This code produces the same error: <Window x:Class="TestApp.TestWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="TestWindow" Height="400" Width="500" WindowStyle="None" WindowState="Maximized"> <Window.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source=

WPF - Resource not loading from Generic.xaml

纵饮孤独 提交于 2019-11-29 02:27:30
问题 Themes\Generic.xaml: <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="WPF Commons;component/Controls/Layout/Foo/FooItem.xaml" /> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> Controls\Layout\Foo\FooItem.xaml: <Style TargetType="{x:Type l:FooItem}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate

What is the easiest way to share resources between UserControls in a WPF User Control library?

柔情痞子 提交于 2019-11-29 02:10:28
There are a WPF User Control library and two (or more) User Controls in it. I need to use the same style in both user controls. How can I share this style? For example: This is the style: <Style x:Key="customLabelStyle" TargetType="Label"> ... </Style> User control A: <UserControl x:Class="Edu.Wpf.Example.UserControlA" ...xmlns stuff... > <Grid> ... some xaml markup... <Label Style="{StaticResource customLabelStyle}"/> </Grid> </UserControl> UserControl B: <UserControl x:Class="Edu.Wpf.Example.UserControlB" ...xmlns stuff... > <Grid> ... some another xaml markup... <Label Style="

Add ResourceDictionary to class library

◇◆丶佛笑我妖孽 提交于 2019-11-29 01:11:01
I created a class library which is contained of WPF Windows and some user controls inherited from my c# classes that helps me to customize certain wpf controls. Now I want to add ResourceDictionary, to help me share styles between my wpf classes. Is it possible? Thx. EDIT: resource dictionary file located in MY.WpfPresentation.Main project (named Styles.xaml): <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid" xmlns:dxgt="http://schemas