Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
85
ViewSettings.ShouldScrollItemsIntoInitialPosition problem
posted

Hi guys,

I'm using NetAdvantage for WPF 2007 vol. 1 and I get a problem if I set ShouldScrollItemsIntoInitialPosition to false. My items simply does not show in the CarouselListBox if I clear the items collection and then adds items to it again.

What can be causing this kind of problem?

What I'm doing is that I use the CaroselListBox to display different kinds of objects, and by double clicking an object, I can drill down to the next level of that object. When I drill up and down, I need to display objects of a different type so I have created a ControlTemplate for each of the object types I want to display in the CarouselListBox. Based on the type of the object, I change the ItemContainerStyle.
So in short I do the following;
1) CarouselListBox.Items.Clear();
2) CarouselListBox.Items.Add(myObject);
3) CarouselListBox.ItemContainerStyle = myStyle;

Also, jumping do a different part of my application and then back seems to make the items in my listbox appear as expected.

-Thanks!

Update: Having investigated a bit, I have discovered that this only happens if I add just 1 object to the items collection and ItemsPrPage is set to 1.
If there is only one item, I have to set ShouldScrollItemsIntoInitialPosition to true in order for the item to get displayed in the ListBox...i guess this is a bug?
A different workaround which works (but I don't like it at all...) is to create a dummy class (with no properties or anything), create an "empty" DataTemplate for the dummy class, and then add an instance of the dummy class to the items collection, so that there will be at least two objects in the items collection.Next, I have to make sure that the ItemsPrPage property is set to at least 2..."A real hack, this is", as Yoda would have put it.

 

 

Parents
No Data
Reply Children
No Data