我在 Thisaddin.cs 中有这段代码
public void Search(string input)
{
ServerList listofservers = new ServerList();
listofservers.Visibility;
}
ServerList
是一个带有列表框的简单 WPF 表单,仅此而已,但是如何显示 listofservers
?
我找不到 listofserver.show();
最佳答案
所以首先没有名为 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/