dependencyobject

Databinding on a IValueConverter

Does anybody know if it is possible to do databinding on an IValueConverter based class? I have the following converter: [ValueConversion(typeof(int), typeof(Article))] public class LookupArticleConverter : FrameworkElement, IValueConverter { public static readonly DependencyProperty ArticlesProperty = DependencyProperty.Register("...

Is it possible to find out the assembly and file containing a DependencyObject?

Hi girls and guys! I am currently working on a little localization framework for WPF (don't even think about pointing me to locBAML...) and wondered if it was possible to find out the containing assembly of a specified DependencyObject. For example: I have a normal window definition in XAML in the file Window1.xaml. The window contains...

what does this error mean?

Hi All, I'm getting this error: Cannot use a DependencyObject that belongs to a different thread than its parent Freezable What does that even mean? Is it in English? Is the parent frozen, or is it just freezable? Any way to make a parent not freezable, if it makes the error go away? What's happening: I have two opengl winforms ...

Enabling direct content creation in XAML on a dependancy object

I have a class CollectionOfThings. As its name suggests its a simple collection of instances of the Thing class. Thing class has a public default constructor and two simple public get, set properties ID and DisplayName, both are string. CollectionOfThing also has public default constructor. In XAML I would like to use markup like thi...

WPF Binding Confusion: Composite DependencyObject

I have a DependencyObject class composition that looks like the following: public class A : DependencyObject { public AB AB { get { ... } set { ... } } public AB AC { get { ... } set { ... } } } public class AB : DependencyObject { public string Property1 { get { ... } set { ... } } public string Property2 { get { ... } set { ... }...

How to expose xaml properties?

I created a ComboBox subclass and added my functionality. Now I want to expose external properties of the TextBox for example: <a:MyComboBox SpellCheck.IsEnabled="True" TextBox.SelectedText="{Binding X}" /> Is this possible, I maybe didn't choose the wrong particular property but I guess you understand what I mean. Is this possible?...

Is it getting to be time for C# to support compile-time macros?

Thus far, Microsoft's C# team has resisted adding formal compile-time macro capabilities to the language. There are aspects of programming with WPF that seem (to me, at least) to be creating some compelling use cases for macros. Dependency properties, for instance. It would be so nice to just be able to do something like this: [Depen...

Binding to a collection of DependencyObjects in Silverlight 4

As of Silverlight 4 it is possible to data bind against a DependencyObject (instead of a Framework element in previous versions). So far so good, but how do I bind agains a collection of DependencyObjects. The DataContext is not passed from the ObservableCollection to the collection elements, so that the DependencyProperties of the Depe...

WPF custom DependencyProperty notify changes

Hey guys I have a class called MyComponent and it has a DependencyProperty caled BackgroundProperty. public class MyComponent { public MyBackground Background { get { return (MyBackground)GetValue(BackgroundProperty); } set { SetValue(BackgroundProperty, value); } } public static readonly DependencyPrope...

Using Linq methods causes missing references to DependencyObject in WindowsBase

I have some c# source that I want to compile using CodeDom within my application (for a plugin) Everything works fine, except if I use a Linq extension function on some of my collections var dict = new Dictionary<KeyType, ValueType>(); .... dict.Any(KV=>KV.Key == "Some Key"); When I try to compile source that has this code, it CodeDo...

What is the DataContext of a DependencyObject in Silverlight4?

I have read that SL4 introduces the ability to data bind properties on objects that derive from DependencyObjects, where previously data-binding only worked on FrameworkElements or FrameworkContentElements. However, I am not clear on how the binding source is determined when binding properties of DependencyObjects. In the case of Frame...

Keeping track of dependency property value changes at global level

Hi, I am having a number of controls in my application(which user can add to canvas), each having various properties(mostly dependency properties). User can change its properties through property grid(like color, text etc.). I have save functionality implemented, so if user makes any change in canvas we ask him to save the document bef...

Casting error for UIElement on runtime

Hi Guys, I get runtime error when I do this... I have this class... public abstract class AnnObject : DependencyObject and when I do this it compiles fine, but throws a runtime error... AnnObject aa; var b = (DependencyObject)aa; var c = (UIElement)b; The error I get is cannot cast AnnObject to UIElement.... Can someone please b...