简体   繁体   English

Childwindow WPF扩展工具包无法打开

[英]Childwindow WPF extended toolkit not opening

This is my code to open childwindow: 这是我打开childwindow的代码:

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

            location.Show();

But the childwindow doesn't show at all. 但是儿童窗口根本没有显示出来。

This is my xaml for childwindow: 这是我对于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>

Could anybody please clarify what the issue is? 有人可以澄清问题是什么吗?

From the looks of it, you've separated your ChildWindow into a separate control. 从它的外观来看,你已经将ChildWindow分成了一个单独的控件。 That's fine, but it needs to be hosted inside a primary window in order to ever become visible. 这很好,但它需要托管在主窗口内才能变得可见。 Start with the simplest thing possible: 从最简单的事情开始:

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

I think you'll find this works fine (assumes event hookup), so take it from there. 我想你会发现这个工作正常(假设事件连接),所以从那里拿它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM