dependency-properties

Getting Attached property inheritance to propagate

天涯浪子 提交于 2019-12-05 21:39:55
I am having trouble getting an attached property value to propagate down the tree from a parent to a child in the visual hierarchy. The setup is as follows: I have a custom panel that instantiates a Viewport3D. The Panel then handles the child added and removed to create and add an inherited Visual3D class for each child item. I am trying to declare an attached property called AttachedToggle property. I would like to have this property reside in an external owner class called AttachedToggle which implements the single attached dependency property IsChecked and allow either the parent Panel or

UserControl Dependency Property design time

↘锁芯ラ 提交于 2019-12-05 21:35:26
问题 I'm creating a simple User Control in WPF that contains a TextBlock inside a Button. <UserControl x:Class="WpfExpansion.MyButton"..... > <Grid > <Button Background="Transparent" > <TextBlock Text="{Binding Path=Text}"/> </Button> </Grid> </UserControl> And also the "Text" dependency property. public partial class MyButton : UserControl { public MyButton() { InitializeComponent(); this.DataContext = this; } public string Text { get { return (string)GetValue(TextProperty); } set { SetValue

Spring bean fields injection

浪子不回头ぞ 提交于 2019-12-05 17:05:56
问题 Using Spring IoC allows to set bean properties exposed via setters: public class Bean { private String value; public void setValue(String value) { this.value = value; } } And the bean definition is: <bean class="Bean"> <property name="value" value="Hello!"> </bean> Is there any existing plugins/classes for Spring Framework that allows to directly expose bean fields as properties without defining setters? Something like this with the same bean definition: public class Bean { @Property private

Order that DependencyProperties bindings are evaluated?

给你一囗甜甜゛ 提交于 2019-12-05 15:51:16
问题 What determines the order that multiple DepdencyProperties on the same control get evaluated in? I am using the Extended WPF Toolkit PropertyGrid and have both SelectedObject and PropertyDefinitions bound: <extToolkit:PropertyGrid AutoGenerateProperties="False" SelectedObject="{Binding ActiveDataPoint}" PropertyDefinitions="{Binding ActiveDataPoint.Properties}"> The problem is that the OnSelectedObjectChanged fires from the dependency property, and in that changed handler it is referencing

WPF Dependency Properties: Why do I need to specify an Owner Type?

巧了我就是萌 提交于 2019-12-05 14:36:21
This is how I register a DependencyProperty : public static readonly DependencyProperty UserProperty = DependencyProperty.Register("User", typeof (User), typeof (NewOnlineUserNotifier)); public User User { get { return (User)GetValue(UserProperty); } set { SetValue(UserProperty, value); } } The third parameter of the DependencyProperty.Register method requires you to specify the type of the Control where the Dependency Property resides in (in this case, my User Control is called NewOnlineUserNotifier ). My question is, why do you actually specify the type of the owner, and what happens if you

TemplateBinding not working for textbox text

核能气质少年 提交于 2019-12-05 11:41:17
I have a custom control called EnhancedTextBox which is a UserControl that has a TextBox and a Button . To the consumer I want it to mostly look like a TextBox, so I did the following: <UserControl.Template> <ControlTemplate TargetType="textBoxes:EnhancedTextBox"> ... <TextBox Text="{TemplateBinding Text}"... And in EnhancedTextBox I have public static readonly DependencyProperty TextProperty = DependencyProperty.Register("Text", typeof (String), typeof (EnhancedTextBox)); public String Text { get { return (String) GetValue(TextProperty); } set { SetValue(TextProperty, value); } } Yet, when I

Defining a Property in a IValueConverter class

不羁的心 提交于 2019-12-05 08:24:37
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 { get { return (Dictionary<int, LEGOMaterial>)GetValue(MaterialsListProperty); } set { SetValue

How is dependency property implemented?

ぐ巨炮叔叔 提交于 2019-12-05 06:03:52
Can anyone explain how is dependency property implemented? Is it just a static dictionary that is declared in base class with a reference of given instance as a key?I can't find any resources about this in internet... Thanks a lot Szymon Rozga I see two questions: How do dependency properties work? The MSDN article on Properties in WPF is a great series on dependency properties. Should be a good overview to get you started. How are dependency properties implemented? You won't find any resources on this because why would Microsoft want to expose their implementation of DP? That being said, that

Cannot databind DependencyProperty

北城余情 提交于 2019-12-05 01:23:59
问题 I have a UserControl with a DependencyProperty. I set it's value in the host window using a data binding expression. However, it doesn't work as expected. Snippet from the user control's codebehind: public class ViewBase : UserControl { public static readonly DependencyProperty ViewModelProperty = DependencyProperty.Register( "ViewModel", typeof(ViewModelBase), typeof(ViewBase)); public ViewModelBase ViewModel { get { return GetValue(ViewModelProperty) as ViewModelBase; } set { SetValue

Binding UserControl Dependency Property and MVVM

╄→尐↘猪︶ㄣ 提交于 2019-12-05 01:04:57
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://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:DPandMVVM" Title="MainWindow" Height=