I'm building a simple UserControl example with DependencyProperties so that the properties of the control can be changed in XAML (code below).
But of course in my application I don't want this control to have tightly-coupled code-behind, but instead the user control will be a view called "DataTypeWholeNumberView" and it will have its ow...
I have a UserControl called SmartForm which has a DependencyProperty called Status.
In my Window1.xaml, I have the element <local:SmartForm Status="Ready"/>.
I would think then in the constructor of the SmartForm object, that Status would equal "Ready" but instead it equals null.
Why is then the value of the Status property NULL in th...
What's the difference between the two, when should RegisterAttached() be used instead of .Register()?
...
Ordinarily I wouldn't just post an error message on SO, but after a Google search only found one hit, I thought I'd at least open the floor for this error here on SO.
I have a custom control called Sparkline with a dependency property called Values of type unit[]. Here's an example where I use it in a DataTemplate:
<DataTemplate DataT...
Hi,
I have what I believe to be about one of the most simple cases of attempting to bind a view to a dependencyproperty in the view model. It seems that the initial changes are reflected in the view but other changes to the DP do not update the view's TextBlock. I'm probably just missing something simple but I just can't see what it is. ...
I have a dependency property defined in my window as below:
public static readonly DependencyProperty IsGenericUserProperty = DependencyProperty.Register("IsGenericUser", typeof (bool), typeof (MainWindow));
public bool IsGenericUser
{
get { return (bool) GetValue(IsGenericUserProperty); }
set { SetValue(IsGenericUserProperty, v...
Hello,
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...
I'm a little confused on creating a DependencyProperty for properties that depend on external sources. For example, in an ultrasound application I'm writing, I currently have the following in a Managed C++ wrapper (translated to C# for simplicity on here, implementing INotifyPropertyChanged):
public int Gain
{
get { return ultrasoun...
Hi everyone,
Let's say that I've defined a dependency like this:
public class MySampleClass
{public static DependencyProperty MyDoubleProperty = DependencyProperty.Register("MyDouble", typeof(double), typeof(MySampleClass));
public double MyDouble
{
get
{
return (double)GetValue(MyDoubleProp...
When I try to change a CroppedBitmap's SourceRect property at runtime, nothing happens. There's no error, and the property value doesn't actually get changed.
I'm trying to do sprite animation. I have a BitmapSource that contains a spritesheet, which is a single bitmap containing a grid of different poses for the sprite. Then I have a C...
I have a Silverlight custom control with two properties; Text and Id. I have created DependencyProperties for these as per the code below.
public static readonly DependencyProperty TextProperty = DependencyProperty.Register("Text", typeof(string), typeof(LookupControl), new PropertyMetadata(NotifyPropertyChanged));
public static readonl...
I have essentially the same problem discussed here: http://khason.net/blog/dependency-property-getters-and-setters-in-multithreaded-environment/
public static readonly DependencyProperty MyPropertyProperty =
DependencyProperty.RegisterAttached("MyProperty", typeof(bool),
typeof(MyObject), new PropertyMetadata(new Propert...
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...
I made a UserControl that is meant to be updated once every few seconds with data from a serial port. This UserControl should be very simple, consisting of a Label for a field name, and another Label containing the field value. I say that it should be simple, but it doesn't work. It does not update at all, and doesn't even display the...
Hi there,
How do i extend an existing control (ComboBox in my case) to include a new property which i can bind to a property on my view model??
I have a Dependancy Property on the control's class as follows:
public class MyComboBox : ComboBox
{
public static readonly DependencyProperty MyTextProperty =
DependencyProperty.R...
Why would a dependency-property implementation crash my application when I provide a default value?
This segment of code is in the class declaration for my UserControl object. Everything works fine - it compiles and runs perfectly.
public static System.Windows.DependencyProperty DepProp
= System.Windows.DependencyProperty.Regis...
I am looking for a way to expose a property in my ViewModel and have it influenced by two separate controls in my View.
In code view, I am trying to do something like this:
propdp object MyObject...
<MySelector SelectedItem="{Binding MyObject, Mode=TwoWay}" />
<MyEditor DataContext="{Binding MyObject, Mode=TwoWay}" />
The purpose of...
How do I bind an element of a derived <UserControl> to an element of the base <UserControl>?
I have defined a UserControl called Tile as my base class. This would be an abstract base class, if XAML wouldn't balk when I tried to instantiate an object derived from it ...
Anyway, so far Tile only contains a single dependency property:...
Anyone used SL3 validation when binding to dependency properties rather than notification properties?
If so, where did you write your setter validation code? Do you know of any good web examples?
Thanks,
Mark
...
For example, I have a dependency property that changes the ScaleTransform of a Canvas, but if it ever goes below zero it throws an error. Sure, I could just force it to zero in the code if that ever happens, but I'd rather use a better method like using a udouble (unsigned double), which doesn't exist in Silverlight or even setting the m...