ListView/GridView ItemContainerStyleSelector not working RRS feed

  • Question

  • Hey Guys,

    I've been trying to figure out why ItemContainerStyleSelector isn't working on any Item type control. I simply made a class, CustomStyleSelector, that extends StyleSelector. CustomStyleSelector::StyleSelectStyle() returns a ref new Style(). It builds and runs, but when I set a breakpoint in the SelectStyle method I found it the method never gets called. I tired this on a ListView and GridView and neither work.

    Is there some prerequisite to using the ItemContainerStyleSelector?

    Tuesday, March 27, 2012 8:03 PM

All replies

  • Can you post an example of how you are assigning the CustomStyleSelector to your ItemsControls?
    Tuesday, March 27, 2012 11:42 PM
  • Hey Jason,

    I've tried all of these methods:

        <local:CustomStyleSelector x:Key="CustomStyleSelector">
        <ListView ItemContainerStyleSelector="{StaticResource CustomStyleSelector}">
            <x:String>Item 1</x:String>
            <x:String>Item 2</x:String>
            <x:String>Item 3</x:String>
        <ListView ItemContainerStyleSelector="{StaticResource CustomStyleSelector}">
            <ListViewItem>Item 1</ListViewItem>
            <ListViewItem>Item 2</ListViewItem>
            <ListViewItem>Item 3</ListViewItem>
        <ListView ItemContainerStyleSelector="{StaticResource CustomStyleSelector}" ItemsSource="{Binding Items}">

    Neither of them appear to work.

    Wednesday, March 28, 2012 3:08 PM
  • Hi Sebasschion,

    I will take a look at this and see if I can reproduce the issue.

    Wednesday, March 28, 2012 8:48 PM
  • Hey Jason,

    Did you ever happen to reproduce this result?

    Thursday, May 24, 2012 4:05 PM
  • Hi Jason,

    Even I too face same problem. CustomStyleSelector is not initialized.  Unable to set listview.ItemContainerStyleSelector.

    Kindly provide solution




    Friday, July 20, 2012 12:48 PM