dependency-properties

Simple Injector usage for generic command handler

旧街凉风 提交于 2019-12-20 23:24:07
问题 The interfaces,commands and command handler set up as per instructions in Simpleinjector wiki. public interface ICommand { string Name { get; set; } } public class Command1 : ICommand { public string Name { get; set; } } public class Command2 : ICommand { public string Name { get; set; } } public interface ICommandHandler<TCommand> { void Execute(TCommand Command); } public class Command1Handler : ICommandHandler<Command1> { public void Execute(Command1 Command) { Console.WriteLine(Command

Image.Height TemplateBinding does not work

99封情书 提交于 2019-12-20 03:54:29
问题 I have created a CustomControl implemented from Button class in WPF. public class ImageButton : Button { ... public int ImageHeight { get { return (int)GetValue(ImageHeightProperty); } set { SetValue(ImageHeightProperty, value); } } public static readonly DependencyProperty ImageHeightProperty = DependencyProperty.Register("ImageHeight", typeof(int), typeof(ImageButton), new UIPropertyMetadata(32)); ... } And I have resource template like this: <Setter Property="Template"> <Setter.Value>

Allow only OneWayToSource binding mode

☆樱花仙子☆ 提交于 2019-12-20 03:34:13
问题 I have EntitiesUserControl responsible for EntitiesCount dependency property: public static readonly DependencyProperty EntitiesCountProperty = DependencyProperty.Register( nameof(EntitiesCount), typeof(int), typeof(EntitiesUserControl), new FrameworkPropertyMetadata(1, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault)); public int EntitiesCount { get { return (int)this.GetValue(EntitiesCountProperty); } set { this.SetValue(EntitiesCountProperty, value); } } Another (primary) control

Co-opting Binding to listen to PropertyChanged events without a FrameworkElement

喜夏-厌秋 提交于 2019-12-20 02:56:08
问题 I have some nested view models that implement INotifyPropertyChanged . I'd like to bind an event listener to a nested property path (e.g. "Parent.Child.Name" ), much like FrameworkElement dependency properties can be bound to arbitrary nested properties. However, I just want something like a PropertyChanged event listener -- I don't actually have any UI element I'd like to bind. Is there any way to use the existing framework to set up such an event source? Ideally, I shouldn't need to modify

Dependency property in app.xaml.cs

会有一股神秘感。 提交于 2019-12-19 17:11:33
问题 I am new to WPF and the below question may look silly for many, please pardon me. How can I create a dependency property in app.xaml.cs? Actually, I tried to created it. The below code, public static DependencyProperty TempProperty = DependencyProperty.Register("Temp", typeof(string), typeof(App)); public string Temp { get { return (string)GetValue(TempProperty); } set { SetValue(TempProperty, value); } } throws the below compile time errors: The name 'GetValue' does not exist in the current

Error while removing project dependency in VS2010

你说的曾经没有我的故事 提交于 2019-12-18 13:53:06
问题 I have a large solution with number of projects. Some the projects depend on others (never a circular dependency though). When I tried to remove a dependency of a project, I am getting an error message like "The dependency was added by the project system and cannot be removed". What is the cause for this error? How I can solve this? 回答1: I sometimes get this problem when I try to manually edit projects/solutions generated by our CMake system. I solve it manually: Open the dependent .vcproj

Silverlight: How to receive notification of a change in an inherited DependencyProperty

你离开我真会死。 提交于 2019-12-18 10:45:25
问题 I have a control which inherits from (you guessed it) Control. I want to receive a notification whenever the FontSize or Style properties are changed. In WPF, I would do that by calling DependencyProperty.OverrideMetadata() . Of course, useful things like that have no place in Silverlight. So, how might one receive those kinds of notifications? 回答1: I think here is a better way. Still need to see the pros and Cons. /// Listen for change of the dependency property public void

WPF Getter/Setter Not Being Called

南笙酒味 提交于 2019-12-18 07:10:25
问题 I have the following code. The PropertyChanged event is being called but the getter and setter is not. I can't for the life of me see why not. I have other properties where the same thing is happening but the values are being set. This is a custom control, if that makes a difference. When I put a breakpoint at the get/set I get nothing. However, the propertychanged is returning the correct value. Any help is greatly appreciated. /// <summary> /// Identifies the PlacementTarget dependency

Using enum as a dependency property in WPF

拟墨画扇 提交于 2019-12-18 04:54:34
问题 I try to use enum type as a dependency property in my custom control, but always get an error: public enum PriceCategories { First = 1, Second = 2, Third = 3, Fourth = 4, Fifth = 5, Sixth = 6 } public static readonly DependencyProperty PriceCatProperty = DependencyProperty.Register("PriceCat", typeof(PriceCategories), typeof(CustControl), new PropertyMetadata(PriceCategories.First)); }; public PriceCategories PriceCat // here I get an error "Expected class, delegate, enum, interface or struct

Difference between Attached and non-Attached Dependency Properties in Silverlight

回眸只為那壹抹淺笑 提交于 2019-12-18 04:36:15
问题 Okay Stackers, I've spent a good couple of hours on this question, and I want to know if anybody has a definitive answer. For all the research I've done, I can't find ANY difference between .Register and .RegisterAttached in Silverlight . Now, before you jump the gun and tell me that .RegisterAttached is used for attaching a DP to another class, try implementing an Attached Dependency Property using DependencyProperty.Register() . I have found not a single difference, and so I am at a loss as