Overriding the default values ​​of ItemsPanelTemplate in Silverlight 4?

I am trying to override the default template for TabControl in Silverlight. Instead of tabs wrapping around when they are full, I want to make it so that the user can scroll through them like a ListBox. However, Silverlight simply ignores everything that I put in the “ItemsPanelTemplate” and displays the default value. Here is the relevant code:

<swc:TabControl Grid.Row="0" Grid.Column="1" Name="Tabs"> <swc:TabControl.ItemsPanel> <ItemsPanelTemplate> <ScrollViewer> <StackPanel Orientation="Horizontal" /> </ScrollViewer> </ItemsPanelTemplate> </swc:TabControl.ItemsPanel> 

Even if I just add a regular StackPanel, it still doesn’t do anything. I use the Silverlight Toolkit for tabs, so everything I find on the Internet is just for regular WPF and does not work for Silverlight. Thank you so much for the advice.

+4
source share
1 answer

ItemsPanel must have a panel as the root element. You have a ScrollViewer. If you want to add a ScrollViewer, you need to create your own ControlTemplate that wraps ItemsPresenter with a ScrollViewer. The ItemsPresenter will be displayed in the ItemsPanel.

You should be able to use the default Style and ControlTemplate from the Silverlight Toolkit and customize it to your needs. Then include your modified version in your application resources or apply it explicitly to individual tabs.

+2
source

Source: https://habr.com/ru/post/1346966/


All Articles