c# - How can I specify a default property to bind to in Silverlight / WPF? -


Is there a way to specify the default property referred to by path with data binding in XAML? I am looking to be able to do something like archive when using ViewSource binding.

When you bond with a CollectionViewSource inside XAM, it is automatically hooking the path to View Properties.

Example: {binding source = {static resource cvs}}, {binding path = view, source = {static resource cvs}} is similar. Is it possible to do this in a Custom Dependency object or POCO?

Set your property as DataContext Assume that you have this class:

  public class person {public string name {get; Set; } Public Person (String Name) {this.Name = name; }}  

You can set it in a data window, in a window like this:

  this.DataContext = new person ( "Carlo");  

And in the window you have a label, you do this:

  & lt; Label content = "{binding name}" />  

The label will show "Carlo".

Now, if you want to use only as a name binding, you can do this in the window:

  person p = new person ("carlo") ; This.DataContext = p.Name;  

and in the label:

  & lt; Label content = "{binding}" />  

Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -