staticresource

WPF baml bug: EventSetter in static resource being set twice, second time to null

穿精又带淫゛_ 提交于 2019-12-02 03:31:08
If I try to store a collection of SetterBase objects in xaml, that includes and EventSetter, The xaml loader throws an error. The root cause is that the xaml loader tries to set PresentationFramework.dll!System.Windows.EventSetters.Event twice: the first time to the correct value (ButtonBase.Click RoutedEvent) but the second time to null, and this throws an exception. My attached property callback is not involved. Why does it try to add the event to the EventSetter twice and why is it null the second time? I checked that the ctor being used is the default one so, EventSeetter is not

How can I set a dependency property on a static resource?

五迷三道 提交于 2019-12-01 05:40:13
问题 I'm trying to get around the fact that I can't specify a dynamic value for ConverterParameter . See my other question for why I need to bind a dynamic value to ConverterParameter - I don't like the solutions currently posted because they all require what I feel should be unnecessary changes to my View Model. To attempt to solve this, I have created a custom converter, and exposed a dependency property on that converter: public class InstanceToBooleanConverter : DependencyObject,

Static resource shared in merged dictionaries

人走茶凉 提交于 2019-11-30 19:21:01
I'm currently working on having dictionaries of styles and templates that I can dynamically apply to my application. Before this "new wanted" dynamical behavior, I had several resource dictionaries, one for each styled control, that I merged in the App.xaml: <Application.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="ColorsDictionary.xaml"/> <ResourceDictionary Source="ControlsTemplatesDictionary.xaml"/> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> </Application.Resources> Now, I'd like my application to be styled, so I

Binding(Converter) in Code Behind

假如想象 提交于 2019-11-30 15:30:00
<local:LabelTemp x:Key="labelTemplate"/> <DataTemplate x:Key="labelTemp"> <TextBlock Text="{Binding Converter={StaticResource labelTemplate},Path=Item.Items}"/> </DataTemplate> Can anyone help me how to write the above Xaml code into Code Behind C#. Im using this code into Pie Chart LabelTemplate. I don't what is the binding source, or how the Pie Chart LabelTemplate (converter) look like. The best I can come up with that much information is the following: public class LabelTemplate : IValueConverter { public object Convert(object value, Type targetType, object parameter, System.Globalization

Is it possible to supply a type converter for a static resource in WPF?

帅比萌擦擦* 提交于 2019-11-30 12:23:43
I have a newbie WPF question. Imagine my user control has a namespace declaration like this: xmlns:system="clr-namespace:System;assembly=mscorlib" And I have resources for the user control like this: <UserControl.Resources> <system:Int32 x:Key="Today">32</system:Int32> </UserControl.Resources> And then somewhere in my user control I have this: <TextBlock Text="{StaticResource Today}"/> This will cause an error because Today is defined as a integer resource, but the Text property is expecting a string. This example is contrived, but hopefully illustrates the question. The question is, short of

Static resource shared in merged dictionaries

筅森魡賤 提交于 2019-11-30 03:47:17
问题 I'm currently working on having dictionaries of styles and templates that I can dynamically apply to my application. Before this "new wanted" dynamical behavior, I had several resource dictionaries, one for each styled control, that I merged in the App.xaml: <Application.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="ColorsDictionary.xaml"/> <ResourceDictionary Source="ControlsTemplatesDictionary.xaml"/> </ResourceDictionary

Is it possible to supply a type converter for a static resource in WPF?

点点圈 提交于 2019-11-29 13:24:17
问题 I have a newbie WPF question. Imagine my user control has a namespace declaration like this: xmlns:system="clr-namespace:System;assembly=mscorlib" And I have resources for the user control like this: <UserControl.Resources> <system:Int32 x:Key="Today">32</system:Int32> </UserControl.Resources> And then somewhere in my user control I have this: <TextBlock Text="{StaticResource Today}"/> This will cause an error because Today is defined as a integer resource, but the Text property is expecting

Why the StaticResource cannot be resolved in this case?

混江龙づ霸主 提交于 2019-11-29 05:51:42
I have got an exception "Cannot find resource named 'mrg'. Resource names are case sensitive." when I try to do the following: MainWindow.xaml: <Window.Resources> <Thickness Left="0" Right="1" Bottom="2" Top="3" x:Key="mrg" /> </Window.Resources> <Grid> <ItemsControl ItemsSource="{Binding}"> <ItemsControl.ItemTemplate> <DataTemplate> <local:UserControl1 /> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl> </Grid> MainWindow.xaml.cs: public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); List<string> source = new List<string>() { "item1", "item2",

Why the StaticResource cannot be resolved in this case?

时光怂恿深爱的人放手 提交于 2019-11-29 05:49:54
I have got an exception "Cannot find resource named 'mrg'. Resource names are case sensitive." when I try to do the following: MainWindow.xaml: <Window.Resources> <Thickness Left="0" Right="1" Bottom="2" Top="3" x:Key="mrg" /> </Window.Resources> <Grid> <ItemsControl ItemsSource="{Binding}"> <ItemsControl.ItemTemplate> <DataTemplate> <local:UserControl1 /> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl> </Grid> MainWindow.xaml.cs: public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); List<string> source = new List<string>() { "item1", "item2",

How to bind to a StaticResource with a Converter?

▼魔方 西西 提交于 2019-11-29 00:59:05
I want to use a Converter to change the value of a StaticResource before assigning it to a property. Is there a way to simulate a Binding that will just set the value of the StaticResource after converting it? Something like {Binding Value={StaticResource myStatic}, Converter={StaticResource myConverter}} ? This works: <TextBox Text="{Binding Source={StaticResource myStatic}, Converter={StaticResource myConverter}, Mode=OneWay}" /> Note that you have to bind one way, because the binding requires a path attribute otherwise. This makes sense, as otherwise the binding would have to replace the