locked
How to style a ListBox with ItemTemplate, DataBinding and different States across individual controls in the ItemTemplate? RRS feed

  • General discussion

  • Hi there

    Please could someone help with sample code or an idea of how to create this scenario:

    I have a listbox which is databound to a datasource, and contains different controls within the itemtemplate e.g. textblock, button, which have certain properties bound (e.g. Text, Content, Visibility etc).

    I need to style the listbox and listboxitems to a certain defined style created by our graphics people (PSD). The listbox items need to have a normal and mouseover state, which need to INCLUDE the controls in the itemtemplate e.g. the background of the row/item needs to change colour but SO DOES the foreground of the textblock.

    I thought I would create the ListBox, databind it, create the itemtemplate with the controls and databind them (all in my xaml page so that I can bind them easily to my data objects on that page), then create the 2 styles (in App.xaml so that they can be reused for other listboxes) and it would work. Which it does, until you want to modify the states in the style, because you don't have access to individual controls, only a ContentPresenter.

    Please can someone give me a working example of the proper way to do this?

    Thanks so much,

    Debbie

     

    Tuesday, May 26, 2009 6:49 AM

All replies