2012-08-04 99 views
3

有誰知道如何在Outlook加載項中使用WPF,我已經閱讀了一些博客文章,並且我意識到可以在Outlook加載項項目中添加WPF控件。我只想在Outlook加載項中託管完整的WPF應用程序。當outlook ribbon按鈕點擊時很簡單,它應該打開一個WPF應用程序,而不是一個Windows窗體中託管的WPF控制器,可以這樣做嗎?Outlook加載項+ WPF

編輯答案:

要使用WPF在Outlook中添加的項目,首先添加一個WCF UserController中的項目,並在這兩個.XAML文件和cs文件更改「UserController中」到「窗口」。然後你就完成了,你可以做任何你想要的WCF。 更改此>>

<UserControl x:Class="AccessCachedContactsTest.UserControl2" 
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
     xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
     mc:Ignorable="d" 
     d:DesignHeight="300" d:DesignWidth="300"> 
<Grid> 

</Grid> 
</UserControl> 

這個>>

<Window x:Class="AccessCachedContactsTest.UserControl2" 
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
     xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
     mc:Ignorable="d" 
     d:DesignHeight="300" d:DesignWidth="300"> 
<Grid> 

</Grid> 
</Window> 

,改變它的根類.xaml.cs文件 「窗口」。

+0

所以你只是想從Outlook啓動一個應用程序?應用程序是否與Outlook有任何關係? – 2012-08-04 08:35:37

回答

8

要在Outlook外接程序項目中使用WPF,首先將WPF UserControl添加到項目中,並將.XAML文件和.CS文件中的「UserControl」更改爲「Window」。然後你就完成了,你可以用WPF做你想做的事情。改變這種>>

<UserControl x:Class="AccessCachedContactsTest.UserControl2" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    mc:Ignorable="d" 
    d:DesignHeight="300" d:DesignWidth="300"> 
    <Grid> 

    </Grid> 
</UserControl> 

這個>>

<Window x:Class="AccessCachedContactsTest.UserControl2" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    mc:Ignorable="d" 
    d:DesignHeight="300" d:DesignWidth="300"> 
<Grid> 

</Grid> 
</Window> 

,改變它的根類.xaml.cs文件 「窗口」。

+0

有沒有這種方法的警告?它似乎工作正常,但我注意到這個問答已經收到了多少「點」...... – 2012-10-23 14:50:07

+0

它適用於我,我有一個工作解決方案,沒有任何問題。有沒有其他直接的方式可以做到這一點,即使我做了大量的研究,並最終結束了使用這種方法:) – Proceso 2012-11-04 16:56:15

+2

我也必須添加一個對System.Xaml的引用... – 2013-09-25 19:25:02