WPF 高度和宽度(按元素绑定)



>wpf 基于网格的行高和行宽的控制高度和宽度元素绑定到它。

 <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="170" />
            <RowDefinition Height="*"   x:Name="ContentControlRow"/>
            <RowDefinition Height="170"/>
        </Grid.RowDefinitions>
        <TabControl Grid.Row="1" x:Name="Tab" MaxHeight="{Binding   ElementName=ContentControlRow, Path=ActualHeight}" Background="Red" VerticalAlignment="Stretch">
            <TabItem>
            </TabItem>
        </TabControl>
    </Grid>

在上面的代码中,它采用MaxHeight=0。但是我需要的是它应该基于ContentControlRow的高度,并且它应该根据窗口大小而可变。

绑定中将实际高度更改为高度。

<Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="170" />
            <RowDefinition Height="*"   x:Name="ContentControlRow"/>
            <RowDefinition Height="170"/>
        </Grid.RowDefinitions>
        <TabControl Grid.Row="1" x:Name="Tab" MaxHeight="{Binding   ElementName=ContentControlRow, Path=Height}" Background="Red" VerticalAlignment="Stretch">
            <TabItem>
            </TabItem>
        </TabControl>
</Grid>

最新更新