This project has moved and is read-only. For the latest updates, please go here.

ChildWidow bug or how to set Template of ChildWindow

Mar 29, 2012 at 11:50 AM
Edited Mar 29, 2012 at 11:51 AM

Hi, I'm trying to write my own ControlTemplte for ChildWindow, and when I trying to set root element of ControlTemplate like Grid, StackPanel, DockPanel  it gives me an Exception 'Object reference not set to an instance of an object.'


            <extToolkit:ChildWindow x:Name="Popup" WindowStartupLocation="Center" IsModal="True">
                    <ControlTemplate TargetType="{x:Type extToolkit:ChildWindow}">

Is it a bug, or I'm using it wrong?

Mar 29, 2012 at 3:58 PM

Thank you for submitting this issue.  I created the Issue #17727 to solve this problem.  The problem is that the ChildWindow assumes some controls with specific names exist.  If these controls aren't found, an exception is thrown.


Right now, to make your template work, here it the minimum you must set:


<ControlTemplate TargetType="{x:Type xctk:ChildWindow}">
  <Grid x:Name="Root">
    <Grid x:Name="PART_WindowRoot" />

Apr 17, 2012 at 12:55 PM

thanx, it helps but when I'm trying to redesign CloseButton with name = "PART_CloseButton" button began do not close the popup


                <ControlTemplate TargetType="extToolkit:ChildWindow">
                    <Grid x:Name="Root">
                            <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
                        <Grid x:Name="PART_WindowRoot" Background="#221E1F">
                            <Grid Grid.Row="0">
                                    <RowDefinition Height="30"/>
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition Width="50"/>
                                <Border Grid.Column="0" Background="Yellow" x:Name="PART_DragWidget"/>
                                <Button Grid.Column="1" Background="Red" x:Name="PART_CloseButton"/>
                            <ContentPresenter Grid.Row="1"/>

Apr 17, 2012 at 2:13 PM

I created the issue #17868 to investigate on this and see if the default behavior should be changed.  Basically, a click on "PART_CloseButton" will set the ChildWindow.WindowState to WindowState.Closed.  However, it will not hide the popup.


This was done by the following trigger in the default control template:

   <Trigger Property="WindowState" Value="Closed">
      <Setter Property="Visibility" Value="Collapsed" />