Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

WPF ... Set Tab Width to be max Tab Item

$
0
0
The width of the 1st tab changes to be wider "after" selecting the 2nd tab. Is there a way to have the 1st tab start by being the width as the 2nd tab, without selecting the 2nd tab?

The following is some example code that depicts the problem.

    <Window x:Class="Xx.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            Title="MainWindow" Height="350" Width="525">
      <Grid>
        <Grid.ColumnDefinitions>
          <ColumnDefinition Width="*"/>
          <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
          <RowDefinition Height="Auto"/>
          <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <Grid Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2">
          <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="Auto"/>
          </Grid.ColumnDefinitions>

          <StackPanel Grid.Row="0" Grid.Column="0" Orientation="Vertical">
            <Label>Position</Label>
          </StackPanel>
          <TabControl Grid.Row="0" Grid.Column="1" Grid.IsSharedSizeScope="True">
            <TabItem Header="Home">
              <Grid>
                <Grid.RowDefinitions>
                  <RowDefinition SharedSizeGroup="TabRow"/>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                  <ColumnDefinition SharedSizeGroup="TabCol"/>
                </Grid.ColumnDefinitions>
                <Grid>
                  <Grid.RowDefinitions>
                    <RowDefinition SharedSizeGroup="HomeRow"/>
                  </Grid.RowDefinitions>
                  <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" SharedSizeGroup="HomeCol"/>
                  </Grid.ColumnDefinitions>

                  <Label Grid.Row="0" Grid.Column="0">Configuration</Label>
                </Grid>
              </Grid>
            </TabItem>

            <TabItem Header="System">
              <Grid>
                <Grid.RowDefinitions>
                  <RowDefinition SharedSizeGroup="TabRow"/>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                  <ColumnDefinition SharedSizeGroup="TabCol"/>
                </Grid.ColumnDefinitions>
                <Grid>
                  <Grid.RowDefinitions>
                    <RowDefinition SharedSizeGroup="SystemRow"/>
                  </Grid.RowDefinitions>
                  <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" SharedSizeGroup="SystemCol"/>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="Auto" SharedSizeGroup="SystemCol"/>
                  </Grid.ColumnDefinitions>
                  <Button Grid.Row="0" Grid.Column="0" Margin="5,4,5,2">Set Communication</Button>
                  <Button Grid.Row="0" Grid.Column="2" Margin="1,4,5,2">Get Com</Button>
                </Grid>
              </Grid>
            </TabItem>
          </TabControl>
        </Grid>
      </Grid>
    </Window>



Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>