Search code examples
wpfwpf-controlsoutlook-addin

Outlook Add-in + WPF


Does anyone knows how to use WPF in Outlook Add-ins, I have read some blog posts and I realized that it's possible to add WPF controls in Outlook Add-in projects. I just want to host a complete WPF application in a Outlook Add-in. simple when outlook ribbon button clicks, it should open a WPF application, not a WPF controller hosted in a windows form, Can this be done?

Edited answer:

To use WPF in outlook Add-in projects, first add a WCF Usercontroller to the project and change the "UserController" to "Window" in both .XAML file and .CS file. Then you are done, You can do what ever you want with WCF. Change this >>

<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>

to this >>

<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>

And also change the root class of .xaml.cs file to "Window".


Solution

  • To use WPF in outlook Add-in projects, first add a WPF UserControl to the project and change the "UserControl" to "Window" in both .XAML file and .CS file. Then you are done, You can do what ever you want with WPF. Change this >>

    <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>
    

    to this >>

    <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>
    

    And also change the root class of .xaml.cs file to "Window".