dependency-properties

How do You Create a Read-Only Dependency Property?

感情迁移 提交于 2020-01-09 06:09:06
问题 How do you create a read-only dependancy property? What are the best-practices for doing so? Specifically, what's stumping me the most is the fact that there's no implementation of DependencyObject.GetValue() that takes a System.Windows.DependencyPropertyKey as a parameter. System.Windows.DependencyProperty.RegisterReadOnly returns a D ependencyPropertyKey object rather than a DependencyProperty . So how are you supposed to access your read-only dependency property if you can't make any calls

How do You Create a Read-Only Dependency Property?

廉价感情. 提交于 2020-01-09 06:08:25
问题 How do you create a read-only dependancy property? What are the best-practices for doing so? Specifically, what's stumping me the most is the fact that there's no implementation of DependencyObject.GetValue() that takes a System.Windows.DependencyPropertyKey as a parameter. System.Windows.DependencyProperty.RegisterReadOnly returns a D ependencyPropertyKey object rather than a DependencyProperty . So how are you supposed to access your read-only dependency property if you can't make any calls

Cross-ListBox Selects in a Nested ListBox WP7 App

流过昼夜 提交于 2020-01-07 05:36:10
问题 A known "issue" with nesting ListBoxes in a Windows Phone 7 App is that for each parent category their respective child ListBox retains its own SelectedItems list. Well, I have a situation where this is expected behavior, but I'm having issues capturing both the Parent and Child ListBox selected lists. Current Functionality: 1. List item 2. List item 3. Loading of Parent and Child ListBox data is working 4. Multi-select of Parent ListBox items works prefectly 5. Multi-select of Child ListBox

UserControl with DataContext and DependencyProperty

霸气de小男生 提交于 2020-01-06 18:09:02
问题 I want to bind a DependencyProperty and DataContext to my UserControl. DataContext is working, but Setting the DependencyProperty has no effect. This is my UserControl: <MyProperty:MyPropertyControl DataContext="{Binding SelectedPerson}" IsEnabled="True"/> And this is the CodeBehind of my UserControl: public static readonly DependencyProperty IsEnabledProperty = DependencyProperty.Register( "IsEnabled", typeof(Boolean), typeof(MyProperty:MyPropertyControl), new FrameworkPropertyMetadata() {

UserControl with DataContext and DependencyProperty

孤街浪徒 提交于 2020-01-06 18:08:55
问题 I want to bind a DependencyProperty and DataContext to my UserControl. DataContext is working, but Setting the DependencyProperty has no effect. This is my UserControl: <MyProperty:MyPropertyControl DataContext="{Binding SelectedPerson}" IsEnabled="True"/> And this is the CodeBehind of my UserControl: public static readonly DependencyProperty IsEnabledProperty = DependencyProperty.Register( "IsEnabled", typeof(Boolean), typeof(MyProperty:MyPropertyControl), new FrameworkPropertyMetadata() {

Why can I no longer bind GradientStop Color to a Dependency Property of my control?

萝らか妹 提交于 2020-01-06 15:39:13
问题 The summary of my problem: I had created a UserControl where I bound my dependency property "Scheme" to the Color property of a GradientStop , and it worked perfectly. Now, after converting my UserControl to a custom control, this binding no longer works, and I don't know why. This is how I declared my resource dictionaries for my UserControl in the UserControl1.xaml file. In UserControl1.xaml : <!-- Resources --> <UserControl.Resources> <ResourceDictionary> <ResourceDictionary

Validating input which is databound to a DependencyProperty - Silverlight

谁说我不能喝 提交于 2020-01-06 14:00:43
问题 My problem: I would like to validate the user input of a TextBox using the control's ValidatesOnExceptions property. XAML code: DataContext="{Binding RelativeSource={RelativeSource Self}}" ... <TextBox x:Name="TestTextBox" Text="{Binding TestText, Mode=TwoWay, ValidatesOnExceptions=True}" TextChanged="TestTextBox_TextChanged"/> 1 : The validation using a normal property works fine: ViewModel code: private string _testText, public string TestText { get {return _testText;} set { if (value=="!")

Fire trigger in UserControl based on DependencyProperty

好久不见. 提交于 2020-01-05 09:53:40
问题 have a very easy question, but it seems I could not find the answer on the Internet for it. Possibly because I am not looking in the right places. I have a user control with a DependencyProperty of a custom enum type. In XAML I would like to Show/Hide elements based on the value of the enum type. I tried to do this with DataTriggers but I fail to get it working. <UserControl x:Class="WpfApplication1.DisplayIcon" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http:/

DependencyProperty binding not working

 ̄綄美尐妖づ 提交于 2020-01-05 08:53:33
问题 My objective here is to disable and enabled some items on a GUI based on the value of a flag that will be changed during execution in the code behind for the window. I've set up a DependencyProperty to accomplish this. I believe that all I have to do is bind the this property to the appropriate "IsEnabled" properties and everything should work. Something is not hooking up properly so nothing is happening. Am I missing some syntax here or something? Here is the binding in WPF (MainWindow.xaml)

Binding from View-Model to View-Model of a child User Control in Silverlight? 2 sources - 1 target

故事扮演 提交于 2020-01-05 08:29:12
问题 So i have a UserControl for one of my Views and have another 'child' UserControl inside that. The outer 'parent' UserControl has a Collection on its View-Model and a Grid control on it to display a list of Items . I want to place another UserControl inside this UserControl to display a form representing the details of one Item . The parent UserControl's View-Model already has a property on it to hold the currently selected Item and i would like to bind this to a DependancyProperty on the