Neil B
Neil B

Reputation: 269

WPF Container stretch content

I have the following XAML

<TabPanel>
    <TreeView HorizontalAlignment="Left" Margin="0,0,0,0" Name="treeView1" MinWidth="212" SelectedItemChanged="treeView1_SelectedItemChanged" MinHeight="467" />
    <ScrollViewer Margin="0,0,0,0" Name="scrollViewer1" HorizontalAlignment="Stretch" >
        <ContentControl Name="gridView" />
    </ScrollViewer>
</TabPanel>

The Scrollviewer does not stretch to the remaining with of the Tab panel. Does anyone have any idea how to achieve this?

Neil.

Upvotes: 2

Views: 1645

Answers (1)

Stewbob
Stewbob

Reputation: 16899

Your ContentControl is what controls the width of your ScrollViewer. Try this:

    <TabPanel>
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Name="col1" Width="*"/>
            </Grid.ColumnDefinitions>

            <TreeView HorizontalAlignment="Left" 
                      Name="treeView1" Grid.Column="0"
                      MinHeight="467" MinWidth="212" />

            <ScrollViewer Grid.Column="1" Name="scrollViewer1">
                <ContentControl Name="gridView" Width="{Binding ElementName=col1, Path=ActualWidth}"/>
            </ScrollViewer>
        </Grid>
    </TabPanel>

Upvotes: 2

Related Questions