WPF 命名空间问题 - 进程?
尝试从 http://www.munna.shatkotha.com/blog/post/2008/10/26/Light-box-effect-with-WPF.aspx
但是,我似乎无法理解下面“进程”的命名空间或语法权利。
<Border x:Name="panelDialog" Visibility="Collapsed">
<Grid>
<Border Background="Black" Opacity="0.49"></Border>
<!--While Xmal Content of the dialog will go here-->
</Grid>
</Border>
博文接着说......
只需放置两个隐藏和显示对话框的函数即可。 总代码如下。 在下面的代码中,我显示了带有灯箱效果的加载屏幕。 显示模式对话框时,只需调用显示和隐藏等待屏幕方法。 最好将 CPU 扩展作业发送到后台线程,并在后台线程中使用调度程序更新 UI。
<Page x:Class="Home">
<Grid>
<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
<!--All the contents will go here-->
</ScrollViewer>
<Border x:Name="panelLoading" Visibility="Collapsed">
<Grid>
<Border Background="Black" Opacity="0.49"></Border>
<local:TMEWaitScreen></local:TMEWaitScreen>
</Grid>
</Border>
</Grid>
</Page>
代码
#region About Wait Screen
/// <summary>
/// Show wait screen before a web request
/// </summary>
public void ShowWaitScreen()
{
Process del = new Process(ShowWaitScreenUI);
Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, del);
}
private void ShowWaitScreenUI()
{
panelLoading.Visibility = Visibility.Visible;
}
/// <summary>
/// Hide a wait screen after a web request
/// </summary>
public void HideWaitScreen()
{
Process del = new Process(HideWaitScreenUI);
Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, del);
}
private void HideWaitScreenUI()
{
panelLoading.Visibility = Visibility.Collapsed;
}
#endregion
这是我在这一行中遇到问题的
Process del = new Process(ShowWaitScreenUI);
隐藏:我能找到的唯一进程是在 System.Diagnostics 中,并且不带任何参数。 我正在尝试学习的博客文章是否已关闭,或者我只是在错误的地方?
Trying to get this example working from http://www.munna.shatkotha.com/blog/post/2008/10/26/Light-box-effect-with-WPF.aspx
However, I can't seem to get the namespace or syntax right for "Process" below.
<Border x:Name="panelDialog" Visibility="Collapsed">
<Grid>
<Border Background="Black" Opacity="0.49"></Border>
<!--While Xmal Content of the dialog will go here-->
</Grid>
</Border>
The blog post goes on to say.....
Just put two function for hide and display the dialog. Total Code is given bellow. In bellow code I have Displayed a loading screen with light box effect. When displaying modal dialog just invoke show and hide wait screen methods. Its good to send your cpu expansive jobs to background thread and use dispatcher to update UI while you are in background thread.
<Page x:Class="Home">
<Grid>
<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
<!--All the contents will go here-->
</ScrollViewer>
<Border x:Name="panelLoading" Visibility="Collapsed">
<Grid>
<Border Background="Black" Opacity="0.49"></Border>
<local:TMEWaitScreen></local:TMEWaitScreen>
</Grid>
</Border>
</Grid>
</Page>
Here is the codebehind
#region About Wait Screen
/// <summary>
/// Show wait screen before a web request
/// </summary>
public void ShowWaitScreen()
{
Process del = new Process(ShowWaitScreenUI);
Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, del);
}
private void ShowWaitScreenUI()
{
panelLoading.Visibility = Visibility.Visible;
}
/// <summary>
/// Hide a wait screen after a web request
/// </summary>
public void HideWaitScreen()
{
Process del = new Process(HideWaitScreenUI);
Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, del);
}
private void HideWaitScreenUI()
{
panelLoading.Visibility = Visibility.Collapsed;
}
#endregion
I'm having issues with this lines specifically:
Process del = new Process(ShowWaitScreenUI);
The only Process I can find is in System.Diagnostics, and takes no arguments. Is the blog post I'm trying to learn from off,or am I just in the wrong place?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看起来写博客的人忘记定义名为 Process 的自定义委托(这个名字有点奇怪)。
现在应该可以编译它并定义它。
但我反而喜欢这些名字。
实际上你可以重构它以使其变得更简单。
Looks like the person who wrote the blog forgot to define their custom delegate called Process (a bit of an odd name for it).
It should compile now with it defined.
But I like these kind of names instead.
Actually you can refactor this to make more simple.
这里的拼写错误:Process 和 ShowWaitScreenHandler 需要更改为 ShowWaitScreenUIHandler。
DispatcherPriority 需要使用。 右键单击 DispatcherPriority 并选择“解决”。
Typos here: Process and ShowWaitScreenHandler needs to be changed to ShowWaitScreenUIHandler.
DispatcherPriority needs a using. Right click on DispatcherPriority and select Resolve.