Tuesday, 15 January 2013

Declaring list and binding property values via XAML for a custom silverlight control -


I think I have clarified something, but when I am creating custom control in Silverlight, I can declare them and they will be exposed while making XAMML announcements, so I can easily do something like this:

  Public category MyControl: UserControl {public string title {get; Set;}}  

and this:

  & lt; Local: MyControl title = "Hello World" /> Although  

Although the properties are not always the usual type, I can have a complex property, such as a list that defines 1 or more columns and has a field in which to be bound Identifies. The syntax is straight forward to define these values ​​in XAML with existing controls:

  & lt; Local: MyControl title = "People list" & gt; & Lt; Local: MyControl.Columns & gt; & Lt; Local: MyControlColumn Heading = "column1" binding = "{binding name}" /> & Lt; Local: MyControlColumn Heading = "column2" binding = "{binding age}" /> & Lt; / Local: MyControl.Columns & gt; & Lt; / Local: myControl & gt;  

How can I do this in the definition of class:

  public class MyControl: UserControl {public string title {get; Set;} public IEnumerable ItemSource {get; Set;} public supervision qualification & lt; MyControlColumn & gt; Column {get; Set;} //? } Public class MyControlColumn {public string title {get; Set;} public ??? Binding {receive; Set;} //? }  

Has anyone told me in the right direction to create outside lists and binding properties?

column An example for the archive to maintain a personal archive Grab the example archive and remove the set accuser: -

  Personal Observe Collection & lt; MyControlColumn & gt; _columns = new reviewable selection & lt; MyControlColumn & gt; (); Public supervision qualification & lt; MyControlColumn & gt; Column {back {_columns; }}  

For binding properties, it looks like what you may want is the binding type itself System.Windows.Data.Binding . But I think that you should know once that what you want to do with the object after receiving it.

GetValue (TitleProperty); } Set {set value (title, property, value); }} Dependency for public static readability Property title = Dependency Property Registration ("title", typef (string), typef (microcontroll), blank;);

Similarly for ItemSource however you should change the name of the ItemsSource to hold the conference with the existing controls.

I did not help feeling that there is a new invention of the wheel, does not the datagrid or list box or some other similar controls cut for you?


No comments:

Post a Comment