Asked by:
ListView/GridView ItemContainerStyleSelector not working

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?
- Edited by _sebastian_b Tuesday, March 27, 2012 8:24 PM
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:
<UserControl.Resources> <local:CustomStyleSelector x:Key="CustomStyleSelector"> <UserControl.Resource> <StackPanel> <ListView ItemContainerStyleSelector="{StaticResource CustomStyleSelector}"> <x:String>Item 1</x:String> <x:String>Item 2</x:String> <x:String>Item 3</x:String> </ListView> <ListView ItemContainerStyleSelector="{StaticResource CustomStyleSelector}"> <ListViewItem>Item 1</ListViewItem> <ListViewItem>Item 2</ListViewItem> <ListViewItem>Item 3</ListViewItem> </ListView> <ListView ItemContainerStyleSelector="{StaticResource CustomStyleSelector}" ItemsSource="{Binding Items}"> </ListView> </StackPanel>
Neither of them appear to work.
- Edited by _sebastian_b Thursday, May 24, 2012 4:10 PM
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
Regards
ursri
ursri
Friday, July 20, 2012 12:48 PM