Dot NET
Dot NET

Reputation: 4907

Disabling or hiding title bar

I'm using the http://wpfmdi.codeplex.com/ library to handle MDI in my WPF application.

I've got a Canvas which contains a child container, which in turn contains a number of small windows.

I would like to disable the titlebar on my child windows. Is this possible? I haven't found a single property which achieves this, especially since the MdiChild object is of type Control rather than Window.

This is my code for creating an MDIChild, which contains an object of my TableWindow class.

            MdiChild child = new MdiChild()
            {
                MaximizeBox = false,
                MinimizeBox = false,
                Resizable = true,
                ShowIcon = false,
                Content = tableWindow.Content as UIElement
            };

            mainContainer.Children.Add(child);

EDIT:

enter image description here

Upvotes: 0

Views: 1085

Answers (1)

Rohit Vats
Rohit Vats

Reputation: 81313

Since its a Control so you have to override its default template (ControlTemplate).

In source code you will see two xamls - Aero.xaml and Luna.xaml containing the style for MdiChild control. Source code can be seen here. Just get rid of StackPanel(ButtonsPanel) containing buttons and Grid(HeaderContent).

Thats the power WPF gives us, you can customize any control to give it a look whatever you feel like by overriding its ControlTemplate.

EDIT

To override the template you have to redefine it in your xaml. What you have to do is create a style again in your Window resources, set the template for the control and it will automatically override the default control template. Simply copy paste the entire template from here and remove the StackPanel and Grid which i mentioned above.

<Window.Resources>
   <Style TargetType="{x:Type mdi:MdiChild}">
      <Setter Property="Template">
          <Setter.Value>
              <ControlTemplate>
                  <!-- Copy paste entire template here and
                       just remove the StackPanel and Grid -->
              </ControlTemplate>
          </Setter.Value>
      </Setter>
   </Style>
</Window.Resources>

EDIT2

Replace your ControlTemplate with this to disable the title bar but still enable the drag operation and resizable operation for your control -

<ControlTemplate TargetType="{x:Type mdi:MdiChild}">
   <Border Name="BaseBorder" BorderThickness="1" CornerRadius="5,5,0,0"
           Background="{StaticResource BackBorderBackgroundBrush}"
           BorderBrush="{StaticResource BackBorderBrush}">
               <Grid>
                  <Border Name="ContentBorder"
                          Background="{TemplateBinding Background}"
                          BorderBrush="{TemplateBinding BorderBrush}"
                          BorderThickness="{TemplateBinding BorderThickness}">
                         <ContentControl Content="{TemplateBinding Content}" />
                   </Border>
                  <Thumb Name="DragThumb" Height="20" Margin="0,0,40,0"
                         VerticalAlignment="Top" Opacity="0"/>

                   <Rectangle Name="LeftBorder" Width="1" HorizontalAlignment="Left" 
                              RadiusX="9" RadiusY="9"
                              Fill="{StaticResource NearBorderBrush}" />
                   <Rectangle Name="TopBorder" Height="1" VerticalAlignment="Top" 
                              RadiusX="9" RadiusY="9"
                              Fill="{StaticResource NearBorderBrush}" />
                   <Rectangle Name="RightBorder" Width="1" HorizontalAlignment="Right" 
                              RadiusX="9" RadiusY="9"
                              Fill="{StaticResource FarBorderBrush}" />
                   <Rectangle Name="BottomBorder" Height="1" VerticalAlignment="Bottom" 
                              RadiusX="9" RadiusY="9"
                              Fill="{StaticResource FarBorderBrush}" />

                   <Thumb Name="ResizeLeft" Width="6" HorizontalAlignment="Left" 
                          Margin="0,6,0,6" Opacity="0" Cursor="SizeWE"
                          IsHitTestVisible="{TemplateBinding Resizable}" />
                   <Thumb Name="ResizeTop" Height="4" VerticalAlignment="Top" 
                          Margin="6,0,6,0" Opacity="0" Cursor="SizeNS"
                          IsHitTestVisible="{TemplateBinding Resizable}" />
                   <Thumb Name="ResizeRight" Width="6" HorizontalAlignment="Right" 
                          Margin="0,6,0,6" Opacity="0" Cursor="SizeWE"
                          IsHitTestVisible="{TemplateBinding Resizable}" />
                   <Thumb Name="ResizeBottom" Height="6" VerticalAlignment="Bottom" 
                          Margin="6,0,6,0" Opacity="0" Cursor="SizeNS"
                          IsHitTestVisible="{TemplateBinding Resizable}" />
                   <Thumb Name="ResizeTopLeft" Width="6" Height="6" 
                          HorizontalAlignment="Left" VerticalAlignment="Top" Opacity="0" 
                          Cursor="SizeNWSE"
                          IsHitTestVisible="{TemplateBinding Resizable}" />
                   <Thumb Name="ResizeTopRight" Width="6" Height="6" 
                          HorizontalAlignment="Right" VerticalAlignment="Top"
                          Opacity="0" Cursor="SizeNESW"
                          IsHitTestVisible="{TemplateBinding Resizable}" />
                   <Thumb Name="ResizeBottomRight" Width="6" Height="6" 
                          HorizontalAlignment="Right" VerticalAlignment="Bottom" 
                          Opacity="0" Cursor="SizeNWSE"
                          IsHitTestVisible="{TemplateBinding Resizable}" />
                   <Thumb Name="ResizeBottomLeft" Width="6" Height="6" 
                          HorizontalAlignment="Left" VerticalAlignment="Bottom"
                          Opacity="0" Cursor="SizeNESW"
                          IsHitTestVisible="{TemplateBinding Resizable}" />
             </Grid>
       </Border>
</ControlTemplate>

Upvotes: 1

Related Questions