ChildWindow Lock Position or Disable Drag

Mar 9, 2012 at 2:36 PM

Is there currently a way to lock the position of the child window so that it is not draggable?  For example if you set the startup position to cetner, the user is unable to move it from there?

Coordinator
Mar 9, 2012 at 6:19 PM

In the current version (1.5.0), there is no way to lock the position of the ChildWindow.  However, you may alter the default template to make the control harder to move around.  The named part "PART_DragWidget" makes the ChildWindow draggable.  Depending on the version you are using, you may be able to remove that named part.  If not, you can make it useless.

 

Here is the part of the template you will have to modify:

<!-- Header -->
<Border x:Name="PART_DragWidget" Background="Transparent" Grid.Column="1" CornerRadius="5,5,0,0" Margin="1,1,1,0">
  <Grid>
    <Grid x:Name="CaptionHeader" Margin="1,1,105,0" VerticalAlignment="Center">
      <!-- Caption -->
      <ContentControl x:Name="Caption"
                      Margin="5,0,0,0"
                      IsTabStop="False"
                      HorizontalAlignment="Stretch"
                      Content="{TemplateBinding Caption}"
                      Foreground="{TemplateBinding CaptionForeground}" />
    </Grid>
  </Grid>
</Border>

 

Replace it with the following xaml to make the ChildWindow not draggable:

<!-- Header -->
<Border Background="Transparent" Grid.Column="1" CornerRadius="5,5,0,0" Margin="1,1,1,0">
  <StackPanel>
    <Border x:Name="PART_DragWidget" Visibility="Collapsed" />
    <Grid x:Name="CaptionHeader" Margin="1,1,105,0" VerticalAlignment="Center">
      <!-- Caption -->
      <ContentControl x:Name="Caption"
                      Margin="5,0,0,0"
                      IsTabStop="False"
                      HorizontalAlignment="Stretch"
                      Content="{TemplateBinding Caption}"
                      Foreground="{TemplateBinding CaptionForeground}" />
    </Grid>
  </StackPanel>
</Border>

Unfortunately, the ChildWindow can still be moved around with the arrow keys.

Apr 8, 2013 at 10:18 PM
Edited Apr 8, 2013 at 10:19 PM
Can you give an example of how to modify the template ?....Where does the above get pasted.

This is my ChildWindow code:

<extToolkit:ChildWindow Name="SettingsWindow" Height="244" Margin="155,171,0,0" Caption="Settings" Width="680" IsModal="False" WindowState="Closed" Background="#FF1D1D1D" WindowBackground="#FF1D1D1D" BorderThickness="0" CloseButtonVisibility="Collapsed" Foreground="White" CaptionForeground="White" IsManipulationEnabled="False" MaxHeight="244" MaxWidth="690" MinHeight="244" MinWidth="690" SnapsToDevicePixels="False" Focusable="False" IsEnabled="True" WindowStartupLocation="Manual" Grid.ColumnSpan="2">
        <Grid>
                  [ALL MY STUFF]
        </Grid>
    </extToolkit:ChildWindow>
I'm on version 1.9...and I really need to be able to make the pop-up NOT MOVE !!!
I want it front and center,,,and not moveable !

Thanks,

Bazzy
Apr 9, 2013 at 4:51 PM
Here is a total hack that I cannot garantee it will work on the next version:

Create a subclass of ChildWindow and override "OnApplyTemplate"
    public override void OnApplyTemplate()
    {
      base.OnApplyTemplate();
      var windowRoot = GetTemplateChild( "PART_WindowRoot" ) as Grid;
      windowRoot.RenderTransform = null;
    }
Developer
Apr 9, 2013 at 6:32 PM
In the version 2.0 of the toolkit, the childWindow will give an access to events and callbacks of inputs. User will be able to register to these events and handle them to block the movement of the childWindow.