简体   繁体   中英

Childwindow WPF extended toolkit not opening

This is my code to open 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:

<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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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