Childwindow WPF扩展工具包无法打开

时间:2013-04-09 10:17:14

标签: c# .net wpf wpf-4.0

这是我打开子窗口的代码:

 ImageLocation location = new ImageLocation();            
            location.WindowStartupLocation = Xceed.Wpf.Toolkit.WindowStartupLocation.Center;

            location.Show();

但是儿童窗口根本没有显示。

这是我对于childwindow的xaml:

<xctk:ChildWindow x:Class="CXLocalSearch.Dialogs.ImageLocation"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Caption="Image Path"
                  xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
       Height="64" Width="400">
    <Grid x:Name="LayoutRoot">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" MinWidth="63.95"/>
            <ColumnDefinition/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition/>
        </Grid.RowDefinitions>
        <TextBlock Margin="2" TextWrapping="Wrap" Text="Image Path"  VerticalAlignment="Center" HorizontalAlignment="Left"/>
        <StackPanel Grid.Column="1" HorizontalAlignment="Left" Margin="3,2,0,2" Orientation="Horizontal" >
            <TextBox x:Name="txtPath" Margin="0,2" TextWrapping="Wrap" VerticalAlignment="Center" Width="250"/>
            <Button x:Name="btnSave" Content="Save" Click="btnSave_Click"  Width="60" Margin="3,0,0,0"/>
        </StackPanel>
    </Grid>
</xctk:ChildWindow>

有人可以澄清问题是什么吗?

1 个答案:

答案 0 :(得分:2)

从外观上看,您已将ChildWindow分隔为单独的控件。这很好,但它需要托管在主窗口内才能变得可见。从最简单的事情开始:

<Window>
    <Grid>
        <Button Click="...">Click to Show</Button>
        <xctk:ChildWindow x:Name="childWindow">
            <TextBlock>Hello!</TextBlock>
        </xctk:ChildWindow>
    </Grid>
</Window>

我认为你会发现这个工作正常(假设事件连接),所以从那里开始。