桌面和图标之间的WPF窗口(Windows 8.1)

时间:2015-10-14 09:41:23

标签: c# .net wpf windows

我使用过CodeProject的精彩文章。 http://www.codeproject.com/Articles/856020/Draw-Behind-Desktop-Icons-in-Windows 这个项目在Windows 8.1上运行正常

使用Forms的示例。现在我将改变表格 到WPF-Window(使用带有.net 4.5.2的Visualstudio 2015)。

// The WPF-Window for infos behind the icon
public partial class InfoBehindIcon : Window
{
    public InfoBehindIcon()
    {
        InitializeComponent();
        // in .xaml: the decoration switched off
    }
}

// The MainWindow - class
    ....
    private HInfoBehindIcon.InfoBehindIcon infoBehindIcon = new HInfoBehindIcon.InfoBehindIcon(); 

    public MainWindow()
    {
        InitializeComponent();
         ....
        iniDesktopHandlerWPF();

        ... in CodeProject example starting here the Form with
         //   System.Windows.Forms.Application.Run(InfoBIForm);
        ... how to start here the WPF-Window behind the Icon?

    }

    private void iniDesktopHandlerWPF()
    {
       ... Code from CodeProject example 
        if(dc != IntPtr.Zero)
        {
            // here I change the Form to WPF-Window
            infoBehindIcon.Loaded += infoBehindIcon_EventWPF;
        }
    }

    private void infoBehindIcon_EventWPF(object sender, EventArgs e)
    {
        infoBehindIcon.Topmost = false;
        InfoPanel.HW32.SetParent(new WindowInteropHelper(infoBehindIcon).Handle, workerw);
    }

使用Forms运行的版本没有问题。 当我尝试更改WPF时,第二个窗口正在启动但是 它不是在桌面和图标之间运行。 有办法解决这个问题吗? 或者更好的方式进一步使用表格? (对不起,我是C#的新人)

1 个答案:

答案 0 :(得分:0)

问题太简单了。我解决了这个问题

    public MainWindow()
    {
        InitializeComponent();
         ....
        iniDesktopHandlerWPF();

        ... in CodeProject starting here the Form with
         //   System.Windows.Forms.Application.Run(InfoBIForm);
        ... how to start here the WPF-Window behind the Icon?

    }

    public MainWindow()
    {
        InitializeComponent();
         ....
        iniDesktopHandlerWPF();

        ... in CodeProject starting here the Form with
         //   System.Windows.Forms.Application.Run(InfoBIForm);
        ... how to start here the WPF-Window behind the Icon?

        infoBehindIcon.Show();          
    }

现在它适用于我。我没看到......;)