locked
templates RRS feed

  • Question

  • Hi,

    Can someone clarify what templates are in silverlight as I am getting confused with what i have got.
    These 3 objects do what

    ContentTemplate property
    ContentControl
     DataTemplate.
    Friday, June 20, 2008 6:59 AM

Answers

All replies

  • ContentControl - can display any type of content, if the content is anything other than strings, int etc you need to specify how it should look,

    for ex. if you want to display customer object( with firstname and lastname as properties) in the control,  it doesnt make sense to display something like 'customer' in the control, instead we want to display some of the objects properties that is where Datatemplate comes into picture, which will let you specify the layout of different controls and proerties you want to display

     ContentTemplate is actually a datatemplate which will tell how to display content(customer object in our example)

     

    Friday, June 20, 2008 8:49 AM
  •  I am not understanding how to use contentControl or why you need it. Why have it?

    You can display data styled is that the idea? 

     It is hard finding a simple example  on this but can someone give me a small code snipper to see it working in .net?

    Monday, June 23, 2008 8:48 AM
  • yes, many controls inherit from this

    From the sdk

    A ContentControl has a limited default style. If you want to enhance the appearance of the control, you can create a new DataTemplate

    Here is a short list of controls that inherit from ContentControl
                System.Windows.Controls..::.DataGridCell
                System.Windows.Controls..::.DataGridColumnHeader
                System.Windows.Controls..::.DataGridRowHeader
                System.Windows.Controls..::.ListBoxItem
                System.Windows.Controls.Primitives..::.ButtonBase
                System.Windows.Controls..::.ScrollViewer
                System.Windows.Controls..::.ToolTip

    Monday, June 23, 2008 8:59 AM