如何在前景窗口最小化/关闭时始终设置Dialog Visible [英] How to set Dialog Visible always when foreground window is minimised/closed

查看:84
本文介绍了如何在前景窗口最小化/关闭时始终设置Dialog Visible的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



在WPF应用程序中,我想将对话框属性设置为始终存在于后台(windowA)中,即使它被其他人遮挡由于一些帮助按钮点击前景中的窗口,一旦前景窗口关闭(windowB),背景windowA应该是可见的,因此,我对WPF XAML代码进行了以下代码更改





WindowA的Xaml代码



Hi All,

In WPF application, I want to set dialog property to be always present in background(windowA), even though it is obscured by some other window in the foreground due to some help button click, Once the foreground window is closed (windowB) the background windowA should be visible, and hence, I had made following code changes to WPF XAML code


Xaml code for WindowA

 Window x:Class="UI.Windows.WindowA"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

Title="windowA"  Height="410" Width="468" WindowStyle="SingleBorderWindow" ResizeMode="NoResize" Visibility="Visible" WindowStartupLocation="CenterScreen" IsTabStop="True" Background="#E8EDF0" KeyUp="Window_KeyUp">





...............











在WindowsA.Xaml.cs文件中





...............





in WindowsA.Xaml.cs file

...... 
 
publicVisibilityVisibility { get; set; } 
 
......





我在编译时得到以下错误,即使所有命名空间都是如此提到。



错误MC3029:'可见性'会员无效,因为它没有合格的类型名称





另外,我在WindowA中为XAML代码添加了以下属性



(Windows_Status =正常;可见性=可见,IsFocusable = True; IsdisplayedInTaskbar = false)



即使上述设置未启用windowA一次,当WindowB关闭时,我关闭windowB,

(总是WindowA隐藏/不可见)。



详细信息: Windows 7操作系统,VS 2010 IDE



任何解决上述问题的帮助都会非常明显,



问候,



VishalK_90



I get the below error on compilation, even though all namespaces are mentioned.

error MC3029: 'Visibility' member is not valid because it does not have a qualifying type name


Also, I had added the following attributes to XAML code in WindowA

(Windows_Status=Normal; Visibility=Visible, IsFocusable=True; IsdisplayedInTaskbar=false)

even though the above settings does not enable the windowA once, I close the windowB,
(Always WindowA is either hidden/Invisible) when WindowB is closed.

Details: Windows 7 O/S, VS 2010 IDE

Any help in resolving the above would be much appreciable,

Regards,

VishalK_90

推荐答案

我是不确定你需要经历这么多事情你想要什么只需将Window A单独保留......因此它是一个常规的,可见的WPF窗口。然后使用ShowDialog打开Window B.它将自动弹出窗口A的顶部,当用户关闭它时,焦点将返回到窗口A.



您的代码非常脱节但是有一个其他一些事情......不要在代码和xaml中设置属性。可见性属性,具体而言,您将在两个位置进行设置。选择一个或另一个并将所有属性设置放在那里。



其次,尝试使用自动支持的属性声明内置属性的覆盖就像你试图用Visibility做的那样,不会飞。如果要覆盖内置函数,则必须覆盖内置属性和后备依赖项属性方法,因为Visibility是依赖项属性。 (您将看到,如果您参考FrameworkElement.Visibility的MSDN文档)不会以与常规类属性相同的方式从绑定引擎访问DP。
I'm not sure you need to go through so many things to get what you want. Just leave Window A alone... so it is a regular, visible WPF window. Then open Window B using ShowDialog. It will automatically pop-up over top of Window A and when the user closes it, focus will return to Window A.

You code is pretty disjointed but there are a few other things... don't set a property in code and in xaml. The visibility property, specifically, you are setting in both places. Pick one or the other and put all the property settings there.

Secondly, trying to declare, with an auto-backed property, an override for a built-in property, like you are trying to do with Visibility, won't fly. If you want to override the built-in functions, you have to override the built-in property AND the backing dependency property method because Visibility is a dependency property. (You will see that if you refer to the MSDN documentation for FrameworkElement.Visibility) DP's don't get accessed from the binding engine in the same way as regular class properties.


这篇关于如何在前景窗口最小化/关闭时始终设置Dialog Visible的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆