Is it possible to create readonly dependency properties?
It seems DependencyPropertyKey is not in Noesis which is how I typically create readonly properties in WPF. Is there another way to do this in Noesis or is this feature not in yet?
-
sfernandez
Site Admin
- Posts: 2983
- Joined:
Re: Is it possible to create readonly dependency properties?
No, that feature is not implemented in C# yet, I added ticket #1823 to track this feature.
Right now read-only properties can be emulated by making private the property identifier and the setter:
Could that work for you in the meantime?
Right now read-only properties can be emulated by making private the property identifier and the setter:
Code: Select all
public class MyClass : DependencyObject
{
private static readonly DependencyProperty SomethingProperty = DependencyProperty.Register(
"Something", typeof(string), typeof(MyClass), new PropertyMetadata(string.Empty));
public string Something
{
get { return (string)GetValue(SomethingProperty); }
private set { SetValue(SomethingProperty, value); }
}
}
Re: Is it possible to create readonly dependency properties?
Ah yes, that works. Thanks.
Who is online
Users browsing this forum: Ahrefs [Bot], Google [Bot] and 37 guests