Skip to content

fix: replace StackPanel with Grid in TabControl Template to support internal ScrollViewer#87

Open
BevisQiu wants to merge 1 commit into
accntech:mainfrom
BevisQiu:main
Open

fix: replace StackPanel with Grid in TabControl Template to support internal ScrollViewer#87
BevisQiu wants to merge 1 commit into
accntech:mainfrom
BevisQiu:main

Conversation

@BevisQiu

Copy link
Copy Markdown

In the current ControlTemplate of TabControl, the content presenter is wrapped within a StackPanel. This causes an issue where a ScrollViewer placed inside a TabItem fails to function correctly because StackPanel provides infinite space to its children, preventing the ScrollViewer from calculating its viewport size.

This PR replaces the StackPanel with a Grid to ensure that content correctly fills the available space and allows ScrollViewer to trigger scrolling as expected.

I have tested the following XAML, and the ScrollViewer now scrolls correctly:

<TabControl>
    <TabControl.Items>
        <TabItem Header="Preview">
            <ScrollViewer 
                shadui:SmoothScrollAssist.IsEnabled="True"
                shadui:SmoothScrollAssist.BaseStepSize="70"
                shadui:SmoothScrollAssist.SmoothingFactor="20" Margin="20 20 20 0">

                <Border Height="2000">
                    <TextBlock Classes="h1" VerticalAlignment="Center" HorizontalAlignment="Center">Content</TextBlock>
                </Border>

            </ScrollViewer>
        </TabItem>

        <TabItem Header="Code">       

        </TabItem>
    </TabControl.Items>
</TabControl>    

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant