是否可以将我的StackPanel或Grid设置为像CSS这样的绝对位置。CSS中具有元素的Position属性,可以将其设置为相对,绝对且运行良好。
在XAML中可以使Grid,StackPanel使用绝对位置。
您必须使用Canvas
才能在WPF中设置绝对位置。
对于窗口中的按钮,这是一个示例:
<Window x:Class="tobedeleted.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
<Canvas>
<Button Canvas.Left="10" Canvas.Bottom="20">Bottom left</Button>
</Canvas>
</Window>
输出为:
随时询问是否需要帮助。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句