![](/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.