c# - 如何让两个按钮与通用 Windows 平台共享一半的应用程序屏幕宽度

标签 c# windows xaml uwp

我试图通过构建 UWP 应用程序让两个按钮在 Visual Studio 的相对面板布局中共享相同的宽度,但似乎无法找到资源或任何东西来告诉我如何做到这一点。

任何人都可以帮助我或给我一些资源吗?请不要在没有建议的情况下降级这个问题。

最佳答案

虽然@al1Dima 提供的Grid 解决方案也是有效的,但这是一个使用RelativePanel 的解决方案

<RelativePanel>
    <Button x:Name="LeftButton" Content="Left" HorizontalAlignment="Stretch"
        RelativePanel.AlignLeftWithPanel="True" RelativePanel.LeftOf="Divider" />
    <Border x:Name="Divider" RelativePanel.AlignHorizontalCenterWithPanel="True"/>
    <Button x:Name="RightButton" Content="Right" HorizontalAlignment="Stretch"
        RelativePanel.AlignRightWithPanel="True" RelativePanel.RightOf="Divider" />
</RelativePanel>

关于c# - 如何让两个按钮与通用 Windows 平台共享一半的应用程序屏幕宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37934622/

相关文章:

c# - 在 C# 中将 Xml 元素复制到另一个文档

c# - 在 MVVM 模式中使用 ASP.NET MVC 中的 C# 扩展方法

c# - "Inconclusive: Test not run"在 Visual Studio/Resharper 中以 Debug模式运行单元测试时出错

c# - 使用 ReactiveUI 与 PasswordBox 进行两种方式绑定(bind)

c# - 如何编码包含哈希的路径?

python - 如何在cmd中运行不同的python版本

windows - "Can' t 读取文件“尝试在批处理文件中排除目录时

windows - 使用 VB6 + Windows 7 传递 ByRef 的参数

c# - 如何从 Gridview 列内的超链接单击事件中获取绑定(bind)数据

c# - WinRT XAML 工具包可视化错误