[英]Setting Window in WPF to the bottom right
我正在尝试将我的 window 设置在左下角。 window 没有标题栏, height
设置为auto
, SizeToContent
为Height
, WindowStartupLocation
为Manual
设置内容后,我正在执行这两行代码:
Left = SystemParameters.WorkArea.Width - Width - 2;
Top = SystemParameters.WorkArea.Height - Height - 2;
这两行在 SetupWindow() function
InitializeComponent();
foreach (Caller c in callers)
{
CallerLine callerline = new CallerLine();
Hyperlink link = (Hyperlink)callerline.FindName("link");
ContentControl ccname = (ContentControl)callerline.FindName("ccname");
ContentControl ccnumber = (ContentControl)callerline.FindName("ccnumber");
link.RequestNavigate += hyperlink_RequestNavigate;
ccname.Content = c.Name;
ccnumber.Content = " " + c.PhoneNumber;
spCallers.Children.Add(callerline);
}
SetupWindow();
在将 window 设置到新位置之前,我正在完成所有设置工作!
现在 window 设置在屏幕右侧的某个位置,但不在底部。 如何将其设置为右下角?
解决方案是在触发 ContentRendered 时设置 position。 这里的代码:
private void Window_ContentRendered(object sender, EventArgs e)
{
Left = SystemParameters.WorkArea.Width - Width - 2;
Top = SystemParameters.WorkArea.Height - Height - 2;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.