从VSTO前景插件打开WPF窗体 [英] Open WPF form from a VSTO outlook addin

查看:1452
本文介绍了从VSTO前景插件打开WPF窗体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Thisaddin.cs这段代码

I have this code in Thisaddin.cs

public void Search(string input)
{           
    ServerList listofservers = new ServerList();            
    listofservers.Visibility;                    
}



SERVERLIST 是一个简单的WPF形式列表框中完蛋了,但如何显示 listofservers

the ServerList is a simple WPF form with listbox thats it but how to display the listofservers?

我找不到 listofserver.show();

推荐答案

所以首先就没有叫WPF表项,只有用户控制的WPF。所以一旦WPF用户控件在XAML中创建您注意到这是代码

So first of all there is no item called WPF Form, there is only User Control for WPF. So once the WPF UserControl is created in the XAML you notice that this is the code

<UserControl x:Class="SQL_openertak2.ServerList"
             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="454" d:DesignWidth="259" SizeToContent="WidthAndHeight">
    <Grid>
        <ListBox Height="410" HorizontalAlignment="Left" Margin="12,12,0,0" Name="listBox1" VerticalAlignment="Top" Width="242" />
        <Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="12,427,0,0" Name="button1" VerticalAlignment="Top" Width="75" Click="button1_Click" />
    </Grid>
</UserControl>



所以,我已经看过了直通XAML代码。因此,大家可以看到,整个事情是的用户控件
你必须将它更改为窗口,然后你就可以看到在 .Show( )

So i have looked thru the XAML code. So as you can see that the whole thing is USERCONTROL you have to change it to WINDOW then you will be able to see the .Show()

但需注意的是,你还必须更改xaml.cs

But take note that you also have to change the code in the xaml.cs

因为它会是这样默认

public partial class ServerList : UserControl

将其更改为

public partial class ServerList : Window

以及出于显而易见的原因! :)

well for obvious reasons!! :)

这篇关于从VSTO前景插件打开WPF窗体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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