试图让这个例子中工作 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);

唯一的过程中我可以找到是在的系统。诊断,并没有争论。是的博客后我想了解关闭,或者我只是在错误的地方吗?

有帮助吗?

解决方案

错字这里:过程与ShowWaitScreenHandler需要改变到ShowWaitScreenUIHandler

的DispatcherPriority需要使用。右键单击的DispatcherPriority和选择的决心。

其他提示

貌似谁写的博客忘记来定义其自定义的委托称为Process(该位是一个奇怪的名字)的人。

private delegate void Process();

应该现在编译它定义。

但我喜欢这几样名代替。

private delegate void HideWaitScreenHandler();
private delegate void ShowWaitScreenHandler();

其实你可以重构此作简单的多。

private delegate void ShowWaitScreenUIHandler(bool show);

void ShowWaitScreenUIThreaded(bool show)
{
    Process del = new ShowWaitScreenHandler(OnShowWaitScreenUI);
    Dispatcher.Invoke(DispatcherPriority.Normal, del, show);
}

void OnShowWaitScreenUI(bool show)
{
    panelLoading.Visibility = show ? Visibility.Visible : Visibility.Collapsed;
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top