![](/img/trans.png)
[英]How to make an image use it's full width while keeping it's normal height in Xamarin Forms?
[英]How to make expander's height full
我需要一种方法来像第二次捕获一样将“Expander 2”扩展到最大程度。 当我试图将选项卡组件放在扩展器中时,我无法使其全视图。 当我再次尝试从 Visual Studio 内部安排扩展器的高度时,它不允许我。 我还分享了我的XAML
文件。 你能告诉我一个方法吗?
编辑:在我更改 Height="*" 后,仍然存在一个问题,这次我的选项卡组件与扩展器的高度不相关。
<sc:UItemEditScreen>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<ucs:UExpander IsAddButtonVisible="False" IsRemoveButtonVisible="False" AddCommand="{x:Null}" RemoveCommand="{x:Null}" AddCommandParameter="{x:Null}" RemoveCommandParameter="{x:Null}" Caption="Expander 1" IsCaptionVisible="True" CaptionTextVerticalAlignment="Top" AccessMode="Editable" BehaviourType="None" IsRequiredForSave="False" IsRequiredForRead="False" Visibility="Visible" ManageChildren="False" Foreground="#FF565151" FontFamily="Segoe UI" FontSize="11">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="310" />
<ColumnDefinition Width="310" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<ucs:UTextBox IsDialogEnabled="True" IsRequiredForSave="True" BehaviourType="Entry" />
</Grid>
</ucs:UExpander>
<ucs:UExpander IsAddButtonVisible="False" IsRemoveButtonVisible="False" AddCommand="{x:Null}" RemoveCommand="{x:Null}" AddCommandParameter="{x:Null}" RemoveCommandParameter="{x:Null}" Caption="Expander 2" IsCaptionVisible="True" CaptionTextVerticalAlignment="Top" AccessMode="Editable" BehaviourType="None" IsRequiredForSave="False" IsRequiredForRead="False" Visibility="Visible" ManageChildren="False" Foreground="#FF565151" FontFamily="Segoe UI" FontSize="11" Grid.Row="1">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="310" />
<ColumnDefinition Width="310" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<ucs:UTab>
<ucs:UTab.Items>
<ucs:UTabItemsCollection>
<ucs:UTabItem Header="Tab 1" ToolTipService.ShowOnDisabled="True">
<ucs:UTabItem.HeaderForeground>
<Binding Path="IsSelected">
<Binding.Converter>
<dx:BoolToObjectConverter>
<dx:BoolToObjectConverter.TrueValue>
<SolidColorBrush Color="{Binding Path=RibbonSelectedTitleForeground.Color, Mode=OneWay}" />
</dx:BoolToObjectConverter.TrueValue>
<dx:BoolToObjectConverter.FalseValue>
<SolidColorBrush Color="{Binding Path=RibbonUnselectedTitleForeground.Color, Mode=OneWay}" />
</dx:BoolToObjectConverter.FalseValue>
</dx:BoolToObjectConverter>
</Binding.Converter>
</Binding>
</ucs:UTabItem.HeaderForeground>
<Grid />
</ucs:UTabItem>
<ucs:UTabItem Header="Tab 2" ToolTipService.ShowOnDisabled="True">
<ucs:UTabItem.HeaderForeground>
<Binding Path="IsSelected">
<Binding.Converter>
<dx:BoolToObjectConverter>
<dx:BoolToObjectConverter.TrueValue>
<SolidColorBrush Color="{Binding Path=RibbonSelectedTitleForeground.Color, Mode=OneWay}" />
</dx:BoolToObjectConverter.TrueValue>
<dx:BoolToObjectConverter.FalseValue>
<SolidColorBrush Color="{Binding Path=RibbonUnselectedTitleForeground.Color, Mode=OneWay}" />
</dx:BoolToObjectConverter.FalseValue>
</dx:BoolToObjectConverter>
</Binding.Converter>
</Binding>
</ucs:UTabItem.HeaderForeground>
<Grid />
</ucs:UTabItem>
</ucs:UTabItemsCollection>
</ucs:UTab.Items>
</ucs:UTab>
</Grid>
</ucs:UExpander>
</Grid>
</sc:UItemEditScreen>
将 RowDefinition Height = * 设置为 Expander2 所在的第二行。
<sc:UItemEditScreen>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" /> <----- This means rest of the space will be taken
</Grid.RowDefinitions>
</Grid>
更新:
与您要实现的目标相比,您的 Xaml 很奇怪。
请参阅 Expander2 的部分:
<ucs:UExpander Grid.Row="1">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="310" />
<ColumnDefinition Width="310" /> <---- Why fixed width columns an also why 2 of them
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" /> <--- This should be *
</Grid.RowDefinitions>
您有 2 列,每列 310 像素宽,一行具有自动高度。 您的选项卡没有分配 Grid.Row 或 Grid.Column,因此默认情况下它将转到 Row=0, Column=0。
在此处也将该网格行高更改为 * 并找出您有 2 列的原因
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.