带有 WPF 窗口的 Visual Studio 2008 Outlook 2007 插件

发布于 2024-08-23 19:44:55 字数 489 浏览 4 评论 0原文

我在任何地方都找不到这方面的全部内容。首先我要说的是我不想使用旧的 Windows 窗体。我想将一个新的 WPF 窗口添加到 Visual Studio 2008 中的 Outlook 2007 插件项目中。但是,WPF 窗口模板没有显示。我正在关注本教程: http://msdn.microsoft.com/en- us/library/bb410039.aspx,其中甚至包含如何将新的 wpf 窗口添加到 Outlook 2007 插件的图片。唯一的问题是它适用于 Visual Studio 2005。微软肯定没有从 Visual Studio 2008 中删除此功能。我一定做错了什么。

有人对我可以从这里去哪里有任何想法或建议吗?

我在 msdn 上也找不到使用 Visual Studio 2008 的类似教程,这也会很有帮助。

I've not been able to find a whole lot on this anywhere. Let me start by saying I don't want to use the old Windows Form. I want to add a new WPF Window to my outlook 2007 addin project in visual studio 2008. The WPF Window template however does not show up. I was following this tutorial: http://msdn.microsoft.com/en-us/library/bb410039.aspx, which even had a picture of how you could add a new wpf window to your outlook 2007 addin. The only problem is that it is for visual studio 2005. Surely microsoft did not remove this ability from visual studio 2008. I must be doing something wrong.

Does anyone have any ideas or suggestions on where I can go from here?

I also cannot find a similar tutorial on msdn using visual studio 2008, that would be helpful as well.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

太阳公公是暖光 2024-08-30 19:44:55

(答案完全重写)

你是对的,VS 2008 不再在加载项中列出“WPF 窗口”模板。幸运的是,它仍然列出了“WPF 用户控件”模板。使用它。这将为项目添加必要的引用。

然后将生成的 XAML 文件的内容(在我的例子中为 UserControl1.xaml)替换为图 5 中的内容(+ 结束标记)。您现在在 XAML 中拥有一个 Window,而不是声明 UserControl。您还需要编辑生成的 C# 文件。将类名(对我来说是 UserControl1)替换为教程中的名称(Window2)及其构造函数。将派生从 UserControl 更改为 Window。最终结果如下:

public partial class Window2 : Window {
    public Window2() {
        InitializeComponent();
    }

.cs 中的命名空间和类名与 XAML 中的 x:Class 声明相匹配非常重要。

现在,按照教程所说的进行操作(不要忘记调整图像文件的路径,否则它不起作用。教程中的原始行是:

imageSource.UriSource = new Uri(@"C:\Fulvio\img\yast_suse_tour.png");

设置硬盘驱动器上现有图像的路径。

然后它就起作用了 我必须补充一点

,本教程是在 VS 有 XAML 设计器之前编写的,不再需要像教程那样手动添加控件,将其更改为窗口,然后使用工具箱并拖动。删除控件,就像您可能习惯的那样,

但就创建 Outlook 加载项而言,该教程很棒。

(Answer completely rewritten)

You are correct, VS 2008 no longer lists the 'WPF window' template in an add-in. Fortunately, it still lists the 'WPF User Control' template. Use it. This will add the necessary references to the project.

Then replace the contents of the generated XAML file (in my case, it was UserControl1.xaml) by what you have in Figure 5 (+ the end tag). Instead of declaring a UserControl, you now have a Window in the XAML. You also need to edit the generated C# file. Replace the class name (for me, it was UserControl1) by the name in the tutorial (Window2) and its constructor, too. Change the derivation from UserControl to Window. Here is the end result:

public partial class Window2 : Window {
    public Window2() {
        InitializeComponent();
    }

It is quite important that the namespace and class name in the .cs match the x:Class declaration in the XAML.

Now, follow what the tutorial says (not forgetting to adapt the path to the image file, otherwise it doesn't work. The original line in the tutorial is:

imageSource.UriSource = new Uri(@"C:\Fulvio\img\yast_suse_tour.png");

Set the path to an existing image on your hard drive.

And then it works!

I have to add that this tutorial was written before VS had a XAML designer. It is no longer needed to add controls by hand like the tutorial does. Add a user control, change it to a window and then use the toolbox and drag&drop controls, like you may be used to.

But as far as creating an outlook add-in is concerned, the tutorial is great.

王权女流氓 2024-08-30 19:44:55

我真的不喜欢这个解决方案,但它确实有效。我发现 http://www.i-think22.net/archives/2008/08/05/adding-wpf-windows-to-an-existing-windows-form-project/。该文章讨论了向现有 Windows 窗体项目添加 wpf 窗体。我刚刚添加了 wpf 用户控件,这是它提供的唯一选项。然后我将 usercontrol 重命名为 window.更新了参考资料,它可以工作了。

唯一的事情是,我不应该这样做......我仍然希望其他人能想出更好的东西。

I really don't like this solution, but it works. I found http://www.i-think22.net/archives/2008/08/05/adding-wpf-windows-to-an-existing-windows-form-project/. That post talks about adding a wpf form to an existing windows form project. I just added the wpf user control, which was the only option it gave. I then renamed usercontrol to window. Updated the references and it works.

The only thing is, I shouldn't have to do that... I'm still hoping someone else comes up with something better.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文