等到用户单击C#WPF [英] Wait till user click C# WPF
本文介绍了等到用户单击C#WPF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想要当用户单击Button
时等待用户单击Window
的程序,除非通过单击Window
.然后如果获取了它,将处理下一行并显示Point
.
I want when the user clicks the Button
, the program to wait for the user to click on the Window
and would not proceed to the next line of code unless a Point
is acquired by clicking on the Window
. and then if it is acquired the next line will be processed and the Point
will be displayed.
<Window x:Class="WpfApp1.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="450" Width="800">
<Grid>
<Button Content="Pick Point & Display it!" HorizontalAlignment="Left" Margin="301,172,0,0" VerticalAlignment="Top" Width="168" Click="Button_Click" RenderTransformOrigin="1.479,2.177"/>
</Grid>
</Window>
private void Button_Click(object sender, RoutedEventArgs e)
{
var point = WaitTillUserClicks();
MessageBox.Show(point.ToString());
}
private Point WaitTillUserClicks()
{
// Prompt the user for a mouse click and do not proceed unless he has clicked at least once on the Window
}
推荐答案
此处是带有
这篇关于等到用户单击C#WPF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文