dependency-properties

Error while removing project dependency in VS2010

心不动则不痛 提交于 2019-11-30 10:45:50
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? 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 file in your favorite text editor. Find <ProjectReference> tag corresponding to the dependency you want to

Difference between CoreceValueCallback and ValidateValueCallback?

核能气质少年 提交于 2019-11-30 10:09:47
I know that CoerceValueCallback is used to correct a value and that ValidateValueCallback will return true or false. But my question is why we need ValidatevalueCallback ? We can simply use CoerceValueCallback to validate (using if condition) and correct the value. Can you give some practical example of when to use coercion vs. validation? Value coercion is basically to change the value, if the the new value is not as system expected. A best example is Slider control. A Slider has both Minimum and Maximum properties. Clearly, it would be a problem if the Maximum value were allowed to fall

When to use Dependency Properties

蹲街弑〆低调 提交于 2019-11-30 06:45:36
问题 I sometimes think I maybe using Dependency Properties unnecessarily. When do I need to use it? When I have a property that dependes on other properties? Say I have a Color property that I want it to be dependent on properties Hue, Saturation, Luminosity do I use a dependency property? Or what do I use? I controls thats bound to Color to update when properties Hue, Saturation, Luminosity are changed. for now what I did was public byte Hue { get { return _hue; } set { if (_hue == value) return;

Dependency Property Uses in WPF

烂漫一生 提交于 2019-11-30 05:43:39
问题 I am having a hard time figuring out good reasons for the dependency property. Why the System.Controls.TextBox "Text" property a dependency property and not a normal property? What benefits does it serve being a dependency property? One of the things I am trying to accomplish is to add a ValidationRules property to my UserControl which will contain other validation rules. Like here: <customControls:RequiredTextBox.ValidationRules> <validators:NotNullOrEmptyValidationRule ErrorMessage=

How to Expose a DependencyProperty of a Control nested in a UserControl?

浪尽此生 提交于 2019-11-30 05:43:22
问题 I'm trying to bind an Image down from a Window into a UserControl 'Display' thats inside a UserControl 'DisplayHandler'. Display has a DependancyProperty 'DisplayImage'. This is Similar to this, but their answers didn't help with my problem. DisplayHandler also should have the Property 'DisplayImage' and pass down the Binding to Display. But Visual Studio doesn't allow me to register a DependancyProperty with the same name twice. So I tried to not register it twice but only to reuse it:

Is there a way to specify a custom dependency property's default binding mode and update trigger?

杀马特。学长 韩版系。学妹 提交于 2019-11-30 05:34:15
I would like to make it so that, as default, when I bind to one of my dependency properties the binding mode is two-way and update-trigger is property changed. Is there a way to do this? Here is an example of one of my dependency properties: public static readonly DependencyProperty BindableSelectionLengthProperty = DependencyProperty.Register( "BindableSelectionLength", typeof(int), typeof(ModdedTextBox), new PropertyMetadata(OnBindableSelectionLengthChanged)); When registering the property, initialize your metadata with: new FrameworkPropertyMetadata { BindsTwoWayByDefault = true,

WPF DependencyProperties

…衆ロ難τιáo~ 提交于 2019-11-30 04:55:19
问题 I have just realized I've been coercing binding/dependency properties and not really fundamentally understanding the concept. Heres the dependency property: public string Problem { get { return (string)GetValue(ProblemProperty); } set { SetValue(ProblemProperty, value); } } public static readonly DependencyProperty ProblemProperty = DependencyProperty.Register( "Problem", typeof(string), typeof(TextBox)); The XAML is as so: <TextBlock Text="{Binding Path=Problem}"/> I'm manually setting the

Must create DependencySource on same Thread as DependencyObject

為{幸葍}努か 提交于 2019-11-30 03:47:04
问题 I have an application written in wpf, which downloads some webpages, parses html code and saves some values. class ListOfItems { public List<SomeObject> ListToBind; public void DownloadItems() { Task.Factory.StartNew(() => { ... ... if (OnDownloadCompleted != null) OnDownloadCompleted(this, EventArgs.Empty); } } } class SomeObject { public string NameOfItem; public MyClass Properties; } class MyClass { public int Percentage; public SolidColorBrush Color; } This is the object model I'm using.

What are the defaults for Binding.Mode=Default for WPF controls?

谁说我不能喝 提交于 2019-11-30 02:36:58
In WPF Binding.Mode , when selecting Default , it depends in the property being binded. I am looking for some list or some convention or any information for the defaults for the various controls. I mean, what properties are TwoWay by default and so on. Any links, ideas, thoughts and even rants are welcommed! Lars Truijens Similar to UpdateSourceTrigger, the default value for the Mode property varies for each property. User-editable properties such as TextBox.Text , ComboBox.Text , MenuItem.IsChecked , etc, have TwoWay as their default Mode value. To figure out if the default is TwoWay , look

Why dependency properties in WPF has to be Static

点点圈 提交于 2019-11-30 00:22:23
Why a dependency property has to be Static? I have seen that it has been already asked in some post here, but I am not able to understand it properly. It will be great if someone can help me understand with a small snippet too. The magic here is, the declaration of DependencyProperty is static not its value (i.e the memory storage). The declaration that you add with static keyword is just the identifier(key) of the DependencyProperty for a particular DependencyObject . As same identifier/key can be used by all instances of the DependencyObject to identify the property value hence it makes