dependency-properties

Child object property change fires parents DependencyPropertyChanged callback?

安稳与你 提交于 2019-12-23 06:06:03
问题 In defining a base class inheriting an the Animatable , class, I have discovered what I am finding to be some odd behavior. When I create a Child DependencyProperty within a 'Parent' class, then define an instance of that 'Parent' class, then alter a property on the parents child, the PropertyChangedCallback I defined for the Parents Child property fires. In compliance with the requisite Minimal, Complete and Verifiable Example: using System; using System.Collections.Generic; using System

Dependency Properties and Data Context in Silverlight 3

那年仲夏 提交于 2019-12-23 04:23:19
问题 I am working with Silverlight 3 beta, and am having an issue. I have a page that has a user control that I worte on it. The user control has a dependency property on it. If the user control does not define a data context (hence using the parent's data context), all works well. But if the user control has its own data context, the dependency property's OnPropertyChanged method never gets called. Here is a sample: My Main Page: <UserControl x:Class="TestDepProp.MainPage" xmlns="http://schemas

Default value for the 'Options' property cannot be bound to a specific thread

早过忘川 提交于 2019-12-22 18:49:13
问题 I find that when I change a class from public class MarkdownEditorOptions : ObservableObject to public class MarkdownEditorOptions : INotifyPropertyChanged, DependencyObject as I wanted to use dependency properties, I get the error Default value for the 'Options' property cannot be bound to a specific thread. ...\Views\ShellView.xaml Options is declared as a dependency property on ShellViewModel public MarkdownEditorOptions Options { get { return (MarkdownEditorOptions)GetValue

Defining a Property in a IValueConverter class

别来无恙 提交于 2019-12-22 06:31:52
问题 I need to define a DependencyProperty in a converter class because I need this data to make the conversion and this data is in another object, not the one I'm binding to. My converter class is the following: public class LEGOMaterialConverter : DependencyObject, IValueConverter { public DependencyProperty MaterialsListProperty = DependencyProperty.Register("MaterialsList", typeof(Dictionary<int, LEGOMaterial>), typeof(LEGOMaterialConverter)); public Dictionary<int, LEGOMaterial> MaterialsList

Binding UserControl Dependency Property and MVVM

不打扰是莪最后的温柔 提交于 2019-12-22 03:55:27
问题 I have a MainWindow containing a UserControl, both implemented in MVVM-pattern. The MainWindowVM has properties that I want to bind to properties in the UserControl1VM. But this doesn't work. Here's some code (the viewmodels use some kind of mvvm-framework that implement the INotifyPropertyChanged in a ViewModelBase-class but that's hopefully no problem): MainWindow.xaml: <Window x:Class="DPandMVVM.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http:/

Is it possible to use compiled binding (x:Bind) with Relative Source, Templated Parent

夙愿已清 提交于 2019-12-21 22:33:55
问题 I'd like to do something like this is a Style: Value="{x:Bind MyCustomDependencyProp, RelativeSource={RelativeSource TemplatedParent}}" Is that possible? Are there any performance benefits? Using TemplateBinding does not seem to work, with a custom DependencyProperty as described elsewhere here on SO: https://stackoverflow.com/a/8657453 回答1: RelativeSource (with x:Bind) is not supported, therefore this particular scenario won't be possible (at the moment, at least). Using TemplateBinding or

Missing snippet in visual studio

不羁的心 提交于 2019-12-21 08:51:11
问题 Same installation of Visual studio on two machines, but in 1 i cant find the snippet "propdp" for DependencyProperty ? I only have prop/propg, cant really understand why. Is there an addon i have to install? 回答1: Came across this same issue myself today after a fresh install of VS2008 on Win7 64 All I had to do to fix it was to Go to Tools > Code Snippets Manager Select Visual C# from the drop down menu Click Add Select the NetFx30 directory containing the code snippets, in my case it was...

Missing snippet in visual studio

半腔热情 提交于 2019-12-21 08:51:10
问题 Same installation of Visual studio on two machines, but in 1 i cant find the snippet "propdp" for DependencyProperty ? I only have prop/propg, cant really understand why. Is there an addon i have to install? 回答1: Came across this same issue myself today after a fresh install of VS2008 on Win7 64 All I had to do to fix it was to Go to Tools > Code Snippets Manager Select Visual C# from the drop down menu Click Add Select the NetFx30 directory containing the code snippets, in my case it was...

How to subscribe to change DependencyProperty? [duplicate]

有些话、适合烂在心里 提交于 2019-12-21 07:34:29
问题 This question already has answers here : Closed 8 years ago . Possible Duplicate: Listen to changes of dependency property Excuse me for my English. I need to create a class that could subscribe to change DependencyProperty, and depending on the new value of this property to perform some action. Like this: MyClass obj = new MyClass(); obj.Subscribe(TextBox.TextProperty, myTextBox); How can I do this? 回答1: Here is one way of doing it, using the handy DependencyPropertyDescriptor class. var pd

How can I create a custom *write-only* dependency-property?

﹥>﹥吖頭↗ 提交于 2019-12-21 05:21:34
问题 I need to know what the procedure is for making a write-only dependency-property. I can see that the DependencyProperty class does not have a special "Register" method for write-only properties, but I have no idea whether the RegisterAttached method may apply to what I am trying to do. This property needs to be a dependency-property, rather than a simple CLR property. Internally, my class requires a PropertyChangedCallback on this property in order to remain stable. I know that write-only