dependency-properties

ComboBox SelectedValue not changing from binding to Dependency Property

非 Y 不嫁゛ 提交于 2019-12-13 04:39:59
问题 I have a Custom Control: I don't want to get into specifics so for simplicity's sake i have 3 Dependency Properties : MyCustomControl (CS) : public class MyCustomControl : Control { DP Value1 DP InternalValue DP SelectedValue OnValue1Changed() { InternalValue = CalculateBasedOn1(); } static bool _isSetInternally; OnInternalValueChanged() { if(Condition()) { _isSetInternally = true; SelectedValue = e.NewValue; } else { Value1 = FixValue1(); } } OnSelectedValueChanged() { if(_isSetInternally) {

Error: “ 'Subjects' property was already registered by 'Period' ” is raised when more than one control is placed on the form

主宰稳场 提交于 2019-12-13 04:30:20
问题 As you can see in the code below I have created a custom control named Period that inherits from Listbox. In it I have declared a read-only dependancy property named 'Subjects'. When a single Period is placed on the WPF window everything runs fine. However, when I place more than one I get the error mentioned in the title. Here is the Period Class: Public Class Period Inherits System.Windows.Controls.ListBox '-------- PROPERTIES --------' Public ReadOnly Property Subjects() As

How to Reference a Vectored Graphic in Control Binding

二次信任 提交于 2019-12-13 01:59:18
问题 All, I have the following resources which defines a custom CheckBox and the images to use for the checked/un-checked states. <sys:String x:Key="Up"> F1 M 37.8516,35.625L 34.6849,38.7917L 23.6016,50.2708L 23.6016,39.9792L 37.8516,24.9375L 52.1016,39.9792L 52.1016, 50.2708L 41.0182,38.7917L 37.8516,35.625 Z </sys:String> <sys:String x:Key="Down"> F1 M 37.8516,39.5833L 52.1016,24.9375L 52.1016,35.2292L 37.8516,50.2708L 23.6016,35.2292L 23.6016,24.9375L 37.8516,39.5833 Z </sys:String> <Style x

Combobox' SelectedItem bound to a DependencyProperty is not refreshing

百般思念 提交于 2019-12-13 00:33:49
问题 I have a combobox, whose SelectedItem is bound to a dependency property. public IEnumerable<KeyValuePair<int,string>> AllItems { get { return _AllItems; } set { _AllItems = value; this.NotifyChange(() => AllItems); } } public KeyValuePair<int, string> SelectedStuff { get { return (KeyValuePair<int, string>)GetValue(SelectedStuffProperty); } set { SetValue(SelectedStuffProperty, value); LoadThings(); } } public static readonly DependencyProperty SelectedStuffProperty = DependencyProperty

WPF: Dependency Properties & Resources

泄露秘密 提交于 2019-12-12 22:21:11
问题 I found this on MSDN: A dependency property value can be set by referencing a resource. Resources are typically specified as the Resources property value of a page root element, or of the application (these locations enable the most convenient access to the resource). The following example shows how to define a SolidColorBrush resource. XAML: <DockPanel.Resources> <SolidColorBrush x:Key="MyBrush" Color="Gold"/> </DockPanel.Resources> Once the resource is defined, you can reference the

`…is not a DependencyProperty` when using dependency properties and style triggers

不打扰是莪最后的温柔 提交于 2019-12-12 16:49:26
问题 In my UserControl: public ODIF.DeviceChannel Channel { get { return (ODIF.DeviceChannel)GetValue(ChannelDP); } set { SetValue(ChannelDP, value); } } public static readonly DependencyProperty ChannelDP = DependencyProperty.Register("ChannelProperty", typeof(ODIF.DeviceChannel), typeof(ChannelBox), new PropertyMetadata(new ODIF.DeviceChannel())); Then when trying to use my control in XAML and bind to Channel using datatriggers: <local:ChannelBox VerticalAlignment="Top" HorizontalAlignment="Left

Animate dependency properties

浪尽此生 提交于 2019-12-12 16:08:10
问题 I have a custom user control that registrates a dependency property HoverHeight : public sealed partial class VirtualPointer : UserControl { public static readonly DependencyProperty HoverHeightProperty = DependencyProperty.Register("HoverHeight", typeof(double), typeof(VirtualPointer), new PropertyMetadata(1.0,OnHoverHeightChanged)); public double HoverHeight { get { return (double)GetValue(HoverHeightProperty); } set { SetValue(HoverHeightProperty, value); } } ... I use this property to

Bind to an attached behavior on a Storyboard

家住魔仙堡 提交于 2019-12-12 15:14:56
问题 I have created an attached dependency property for Storyboards, with the intention of enabling me to call a method on my ViewModel when a Storyboard Completed event fires: public static class StoryboardExtensions { public static ICommand GetCompletedCommand(DependencyObject target) { return (ICommand)target.GetValue(CompletedCommandProperty); } public static void SetCompletedCommand(DependencyObject target, ICommand value) { target.SetValue(CompletedCommandProperty, value); } public static

All WPF control properties are dependency properties. True or False?

对着背影说爱祢 提交于 2019-12-12 15:09:10
问题 While answering this question I noticed that I have never come across any property which is not a dependency property (WPF Controls, no 3rd party controls). Although, when I started with WPF I remember reading somewhere that "more then 90% of properties of WPF controls are dependency properties". Can anyone give examples/links of CLR properties in WPF controls and why it's so? Update: Came across this lecture: http://www.miszalok.de/Lectures/L17_WPF/C4_DependencyProperties

How can I most easily determine whether a property is a dependency property?

蓝咒 提交于 2019-12-12 12:35:49
问题 I recently had an issue with databinding to the Visibility property of a DataGridTextColumn. The confusion arose because this property is a dependecy property in WPF but not in Silverlight. I don't think that the MSDN documentation makes this very clear. The following is the only related text for WPF. "For information about what can influence the value, see DependencyProperty." http://msdn.microsoft.com/en-us/library/system.windows.controls.datagridcolumn.visibility(v=VS.100).aspx 回答1: