【问题标题】:Fluid Layouts in UWPUWP 中的流体布局
【发布时间】:2019-11-19 02:14:33
【问题描述】:

我试图在屏幕最右侧的列表视图中放置一个按钮,但没有成功。

到目前为止,我有这个,

<DataTemplate x:DataType="local:SSS">
                    <RelativePanel HorizontalAlignment="Stretch">
                        <TextBlock
                            x:Name="A"
                            Text="{x:Bind xxx}" 
                            FontWeight="Bold"
                            RelativePanel.AlignLeftWithPanel="True"
                            RelativePanel.AlignTopWithPanel="True"
                            RelativePanel.AlignBottomWithPanel="True"/>
                        <TextBlock
                            x:Name="B"
                            Text="{x:Bind xxx}" 
                            TextAlignment="Right"
                            RelativePanel.RightOf="A"
                            RelativePanel.AlignRightWithPanel="True"
                            RelativePanel.AlignTopWithPanel="True"
                            RelativePanel.AlignBottomWithPanel="True"/>
                    </RelativePanel>                     
                </DataTemplate>

如何将第二个文本块推到屏幕的最右侧?

|A                               B|

【问题讨论】:

标签: xaml uwp


【解决方案1】:

这是列表视图的常见问题。您需要强制这些项目在它们的样式中占据整个宽度。请参阅链接的帖子...

Link to answer by Grace Feng

你需要的东西:

<ListView.ItemContainerStyle>
    <Style TargetType="ListViewItem">
        <Setter Property="HorizontalContentAlignment" Value="Stretch" />
    </Style>
</ListView.ItemContainerStyle>

【讨论】:

    猜你喜欢
    • 2012-04-08
    • 2019-06-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-03-01
    • 2010-11-11
    • 1970-01-01
    相关资源
    最近更新 更多