4

SilverlightでTabControlのデフォルトテンプレートをオーバーライドしようとしています。タブがいっぱいになったときにタブを折り返すのではなく、リストボックスのように、ユーザーがタブをスクロールできるようにします。ただし、Silverlightは、「ItemsPanelTemplate」に入れたものをすべて無視し、デフォルトをレンダリングします。関連するコードは次のとおりです。

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

通常のStackPanelを入れただけでも、何もしません。タブにSilverlightToolkitを使用しているので、オンラインで見つけたものはすべて通常のWPF専用であり、Silverlightでは機能しません。アドバイスありがとうございます。

4

1 に答える 1

2

The ItemsPanel needs to have a Panel in it as the root element. You have a ScrollViewer. If you want to add a ScrollViewer, you'd have to create a custom ControlTemplate that wraps the ItemsPresenter with a ScrollViewer. The ItemsPresenter will be where the ItemsPanel is shown.

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

于 2011-04-06T20:30:00.317 に答える