4

I am working with telerik WPF controls to create desktop appln.

I want to make Radwindow looks like a UserControl (without min, max, close buttons and title) and later load this as a content in RadPane.

If I create my view as UserControl, I can set that as content in RadPane.

I can do same with RadWindow i.e. setting it as a content in RadPane but problem is I can still see Header, Close buttons

How to hide 'Title bar' of RadWindow?

enter image description here

kmatyaszek
  • 19,016
  • 9
  • 60
  • 65

2 Answers2

0

You can do this with that trick.

    private void HideHeader()
    {
        var myWindow = new RadWindow();
        var header = FindVisualChildren<Grid>(myWindow).FirstOrDefault(elem => elem.Name == "Header");
        if (header != null)
            header.Visibility = Visibility.Collapsed;
    }

    private static IEnumerable<T> FindVisualChildren<T>(DependencyObject parent)
        where T : DependencyObject
    {
        var childrenCount = VisualTreeHelper.GetChildrenCount(parent);
        for (var i = 0; i < childrenCount; i++)
        {
            var child = VisualTreeHelper.GetChild(parent, i);

            if (child is T children)
                yield return children;

            foreach (var other in FindVisualChildren<T>(child))
                yield return other;
        }
    }
Spawn
  • 935
  • 1
  • 13
  • 32
-1

You should create one UserControl and use it in RadWindow and RadPane.

<UserControl x:Class="Q52017840.MyUserCotnrol"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:local="clr-namespace:Q52017840"
             mc:Ignorable="d" 
             d:DesignHeight="450" d:DesignWidth="800">
    <Grid>
        <TextBlock Text="My user control" />
    </Grid>
</UserControl>

If you created UserControl with name MyUserControl you can use it e.g. in this way:

RadWindow radWindow = new RadWindow();
radWindow.Width = 400;
radWindow.Height = 300;
radWindow.Content = new MyUserCotnrol();

RadPane radPane1 = new RadPane();
radPane1.Header = "Document 1";
radPane1.Content = new MyUserCotnrol();
kmatyaszek
  • 19,016
  • 9
  • 60
  • 65
  • I am sorry. I guess you didn't understand my question. Yes I can create a 'UserControl' and load it in 'RadWindow' or 'RadPane'. but doing so, I can't change theme of it. So, I want to use a Radwindow instead of UserControl and load 'RadWindow' as content in 'RadPane'. Because, I have control to change themes of 'RadWindow' dynamically. Until this it is fine. But, when I add 'RadWindow' in Radpane, it is still showing min, max, close buttons and title bar in my rad pane tab which I want to hide. – Upendhar Singirikonda Aug 27 '18 at 05:10
  • @UpendharSingirikonda If you want to reuse control you should follow my advice. If you have a problem with theme mechanism please create another question with good source code example e.g. you can create example project on GitHub. – kmatyaszek Aug 27 '18 at 19:22
  • I achieved it by changing the BG color using style – Upendhar Singirikonda Aug 29 '18 at 17:10