c# - 从 VSTO outlook 插件打开 WPF 窗体

标签 c# wpf vsto

我在 Thisaddin.cs 中有这段代码

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

ServerList 是一个带有列表框的简单 WPF 表单,仅此而已,但是如何显示 listofservers

我找不到 listofserver.show();

enter image description here

最佳答案

所以首先没有名为 WPF Form 的项目,只有 WPF 的用户控件。因此,一旦在 XAML 中创建了 WPF UserControl,您就会注意到这是代码

<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 代码。所以你可以看到整个事情是 USERCONTROL 您必须将其更改为 WINDOW 然后您将能够看到 .Show()

但请注意,您还必须更改 xaml.cs 中的代码

因为默认是这样的

public partial class ServerList : UserControl

改成

public partial class ServerList : Window

好吧,原因很明显!! :)

关于c# - 从 VSTO outlook 插件打开 WPF 窗体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10164140/

相关文章:

c# - C# 中 foreach() 的复杂性。网

c# - 如何检测鼠标是否直接在 WPF 中的对象类型上

wpf - 使用 MVVM 在 wpf 的组合框中取消选择

vsto - 在 Office 中找不到功能区的大多数(全部?)选项卡名称列表

c# - Word VSTO 覆盖 CTRL+Z/CTRL+Y

c# - 自定义指标遥测不会出现在 Application Insights 的指标浏览器中

c# - Azure 表存储 ExecuteBatchAsync 未运行异步

c# - 来自 ASP.NET 的数据包数据嗅探

sql - WPF比较两个数据表以查找匹配值

ms-word - MS Office Word VSTO “Load On Demand”