dynamicresource

SelectedColor binding doesn't update from ColorPicker to Model

前提是你 提交于 2019-12-01 10:39:32
I have a WPF application where I need to allow to change appearance (backgrounds and foreground mostly). So i bind them to dynamic resources which defined application-wide in App.resources . I also decided to use a ColorPicker from wpftoolkit (v2.5.0) in my Settings window simplified example App.xaml <Application x:Class="WpfColors.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" StartupUri="MainWindow.xaml"> <Application.Resources> <SolidColorBrush x:Key="BgBrush" Color="Gray"/> </Application.Resources> </Application

SelectedColor binding doesn't update from ColorPicker to Model

我的梦境 提交于 2019-12-01 08:22:42
问题 I have a WPF application where I need to allow to change appearance (backgrounds and foreground mostly). So i bind them to dynamic resources which defined application-wide in App.resources . I also decided to use a ColorPicker from wpftoolkit (v2.5.0) in my Settings window simplified example App.xaml <Application x:Class="WpfColors.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" StartupUri="MainWindow.xaml">

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}"

Why Storyboard value wouldn't get from a resource or binding?

强颜欢笑 提交于 2019-11-29 12:50:33
I have construction below and it works: <Storyboard x:Key="GrowOnStart"> <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(Canvas.Left)" Storyboard.TargetName="window"> <EasingDoubleKeyFrame KeyTime="0" Value="1024"/> Why it doesn't work if I try something like this: <EasingDoubleKeyFrame KeyTime="0" Value="{DynamicResource StartingPositionLeft}"/> And yes, I defined the resource before the storyboard. And the statement like the next one wouldn't work either: <EasingDoubleKeyFrame KeyTime="0" Value="{Binding StartingPositionLeft}"/> And yes it's a public property on code behind and

DynamicResource color doesn't work for BorderBrush on a Border - Bug?

你。 提交于 2019-11-29 09:46:35
问题 Visual Studio 2010 | .NET/WPF 4.0 I think this might be a WPF bug, but I can't seem to find a bug report about it. To cover the possibility that I'm just missing something obvious, I turn to stackoverflow for answers! Consider this xaml (nothing in the codebehind): <Window x:Class="DownExpanders.BorderTest" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="BorderTest" Height="300" Width="300"> <Window.Resources>

Place storyboard in application resources

江枫思渺然 提交于 2019-11-29 02:57:27
问题 I need to use the same storyboard in several places therefore I placed the storyboard inside my Application.Resources . When I try to execute the storyboard the only problem is that I need to reference the target that I want to animate. Here is my storyboard: <System:String x:Key="target">border2</System:String> <Storyboard x:Key="stHeight"> <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Height)" Storyboard.TargetName="{DynamicResource target}">

Binding to resource key, WPF

只谈情不闲聊 提交于 2019-11-29 01:42:12
I have a ResourceDictionary with some images: <BitmapImage UriSource="..\Images\Bright\folder-bright.png" x:Key="FolderItemImage" /> I've create a HierarchicalTemplate for treeview items like the following: <HierarchicalDataTemplate ItemsSource="{Binding VisibleChildren}" DataType="{x:Type st:StructureTreeItem}"> <StackPanel Orientation="Horizontal"> <TextBlock Text="{Binding ImageResourceKey}" /> <Image x:Name="iIcon2" Source="{DynamicResource FolderItemImage}"/> <Image x:Name="iIcon" Source="{DynamicResource {Binding ImageResourceKey}}"/> </StackPanel> </HierarchicalDataTemplate> Now, when

Is there a significant performance cost to DynamicResource instead of StaticResource?

♀尐吖头ヾ 提交于 2019-11-28 23:21:15
Our designer is using Blend to style our WPF application. When he chooses local resources for properties, Blend will apply them as a {DynamicResource} instead of a {StaticResource} . My guess is that Blend does this because it enables the app to be re-themed at runtime without having to restart it. My question is: is there a significant performance cost to this additional lookup? Should we ask the designer to go back and manually change those Dynamics to Statics? Here is a great SO question that explains the difference between the types: What's the difference between StaticResource and

Error when using StaticResourceExtension inside Style.Resources

半世苍凉 提交于 2019-11-28 07:12:04
问题 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=

Why Storyboard value wouldn't get from a resource or binding?

≯℡__Kan透↙ 提交于 2019-11-28 06:36:11
问题 I have construction below and it works: <Storyboard x:Key="GrowOnStart"> <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(Canvas.Left)" Storyboard.TargetName="window"> <EasingDoubleKeyFrame KeyTime="0" Value="1024"/> Why it doesn't work if I try something like this: <EasingDoubleKeyFrame KeyTime="0" Value="{DynamicResource StartingPositionLeft}"/> And yes, I defined the resource before the storyboard. And the statement like the next one wouldn't work either: <EasingDoubleKeyFrame