This is a migrated thread and some comments may be shown as answers.

RadWindow as MainWindow ignores xaml properties

2 Answers 78 Views
Window
This is a migrated thread and some comments may be shown as answers.
Ken
Top achievements
Rank 1
Ken asked on 02 May 2020, 05:15 PM

Windows 10 Pro 64, Visual Studio 2019, Telerik.UI.for.Wpf.NetCore.Xaml 2020.1.218

I'm starting  up a new project and want to use RadWindow as my main window, so I found this explanation of what to do and followed it:

https://www.telerik.com/support/kb/wpf/window/details/how-to-use-radwindow-as-main-window

My problem is that the RadWindow seems to be ignoring the properties I put into the MainWindow.xaml, so it displays a main window just large enough to contain the title bar in the upper left corner of my desktop with "RadWindow" as the header.  I added code in the MainWindow's  constructor in the code-behind and that works.  What have I missed?

MainWindow.xaml:

<telerik:RadWindow x:Class="MainWindow"
    Header="Program Launcher" WindowStartupLocation="CenterScreen" Height="200" Width="400">
    <Grid>
         
    </Grid>
</telerik:RadWindow>

 

MainWindow.xaml.cs:

using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Telerik.Windows.Controls;
 
namespace ProgramLauncher
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : RadWindow
    {
        public MainWindow()
        {
            //InitializeComponent();
            //    Header = "Program Launcher";
            //    WindowStartupLocation = WindowStartupLocation.CenterScreen;
            //    Height = 200;
            //    Width = 400;
        }
    }
}

 

Note: Code that sets window properties is coded out to show initial conditions that caused the problem.

app.xaml:

<Application x:Class="ProgramLauncher.App"
    <!--StartupUri="MainWindow.xaml">-->
    <Application.Resources>
      <ResourceDictionary>
          <ResourceDictionary.MergedDictionaries>
          </ResourceDictionary.MergedDictionaries>
      </ResourceDictionary>
    </Application.Resources>
</Application>

 

app.xaml.cs:

using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Windows;
 
namespace ProgramLauncher
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : Application
    {
        public App()
        {
           //this.InitializeComponent();
        }
        protected override void OnStartup(StartupEventArgs e)
        {
            new MainWindow().Show();
            base.OnStartup(e);
        }
    }
}

 

Bad Main Window.png shows the main window as it originally appeared when I was assigning the properties only in the xaml.  Good Main Window.png shows how the main window should appear, centered on my screen.  That's how it looks after I added the code to MainWindow's constructor to set the properties.

2 Answers, 1 is accepted

Sort by
0
Ken
Top achievements
Rank 1
answered on 04 May 2020, 09:58 PM
Reinstalled Telerik UI for WPF and it's working now.
0
Dinko | Tech Support Engineer
Telerik team
answered on 06 May 2020, 05:10 AM

Hi Ken,

I am happy to hear that you have found a solution to your scenario. If you have any other questions, you can open a new forum thread with your questions inside.

Regards,
Dinko
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Tags
Window
Asked by
Ken
Top achievements
Rank 1
Answers by
Ken
Top achievements
Rank 1
Dinko | Tech Support Engineer
Telerik team
Share this question
or