Please help me visualize RADWindow as Shell (MainWindow) of Prism 6 application.

3 posts, 1 answers
  1. Eugene
    Eugene avatar
    83 posts
    Member since:
    Jan 2016

    Posted 23 Mar Link to this post

    Hi! I appreciate your time very high but this time I can't go without your help. Please don't consider me as lazy and slothful programmer but I've tryed to solve my problem for all day today and my efforts to solve it remain ineffectual. The matter is in the following: I've studied the Prism 6 application solution you give me as answer on my question at http://www.telerik.com/forums/can-i-use-telerik-styles-for-prism-window-%28wpf%29-and-prism-usercontrol-%28wpf%29-that-are-supplied-with-prism-template-pack-for-prism-6  and try to write similar application myself. But all that is achieved by me here is that the solution of this application is succsesfully built without errors and runs. But herewith the MainWindow of my application is not displayed on the computer screen! I attached the structure of my application solution  in Teleril_Prism_Unity.PNG file.I use MS VS 2015 Professional (russified).

    Below is App.config:

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
      <startup>
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
      </startup>
    </configuration>

    Below is Bootstrepper:

    class FcBootstrapper : UnityBootstrapper
        {
            protected override DependencyObject CreateShell()
            {
                return Container.Resolve<MainWindow>();
            }

            protected override void InitializeShell()
            {
                ((RadWindow)this.Shell).Show();
            }
        }

    Below is App.XAML:

    <Application x:Class="FlowmeterConfigurator.App"
                 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                 xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
                 xmlns:local="clr-namespace:FlowmeterConfigurator"
                 xmlns:views="clr-namespace:FlowmeterConfigurator.Views">
        <Application.Resources>
            <ResourceDictionary>
                <ResourceDictionary.MergedDictionaries>
                    <ResourceDictionary Source="/Telerik.Windows.Themes.Office2013;component/Themes/System.Windows.xaml" />
                    <ResourceDictionary Source="/Telerik.Windows.Themes.Office2013;component/Themes/Telerik.Windows.Controls.xaml" />
                    <ResourceDictionary Source="/Telerik.Windows.Themes.Office2013;component/Themes/Telerik.Windows.Controls.Navigation.xaml" />
                    <ResourceDictionary Source="/Telerik.Windows.Themes.Office2013;component/Themes/Telerik.Windows.Controls.Docking.xaml" />
                </ResourceDictionary.MergedDictionaries>
            </ResourceDictionary>
        </Application.Resources>
    </Application>

    Below is App.XAML.CS:

    public partial class App : Application
        {
            protected override void OnStartup(StartupEventArgs e)
            {
                base.OnStartup(e);

                var bootstrapper = new FcBootstrapper();
                bootstrapper.Run();
            }
        }

    Below is MainWindow.XAML:

    <telerik:RadWindow x:Class="FlowmeterConfigurator.Views.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
            xmlns:prism="http://prismlibrary.com/"
            xmlns:views="clr-namespace:FlowmeterConfigurator.Views"
            prism:ViewModelLocator.AutoWireViewModel="True"
            Header="{Binding Title}" Height="300" Width="300">
        <Grid>

        </Grid>
    </telerik:RadWindow>

    Below is MainWindow.XAML.CS:

    public partial class MainWindow : RadWindow
        {
            public MainWindow()
            {
                InitializeComponent();
            }
        }

    And below is MainWindowViewModel.CS

    public class MainWindowViewModel : BindableBase
        {
            private string _title = "Prism Unity Application with Telerik";

            public MainWindowViewModel()
            {

            }

            public string Title
            {
                get { return _title; }
                set { SetProperty(ref _title, value); }
            }
        }

    I created this application as Telerik Empty Project and after added folders there. Then I added RadWindow in Views folder and named it MainWindow and then deleted MainWindow (which was WPF Window) created with the solution. And after it I aded Prism 6 for WPF library via NuGet. Please reply me (if this is possible of course) why MainWindow is not visualized when the application runs.  I would be very much obliged to you.

    Eugene.

  2. Answer
    Nasko
    Admin
    Nasko avatar
    588 posts

    Posted 23 Mar Link to this post

    Hello Eugene,

    As you are using Implicit Styles the newly created MainWindow will not receive the default Style of RadWindow - you should add the following style after the merged dictionaries to fix this:
    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/Telerik.Windows.Themes.Office2013;component/Themes/System.Windows.xaml" />
                <ResourceDictionary Source="/Telerik.Windows.Themes.Office2013;component/Themes/Telerik.Windows.Controls.xaml" />
                <ResourceDictionary Source="/Telerik.Windows.Themes.Office2013;component/Themes/Telerik.Windows.Controls.Navigation.xaml" />
                <ResourceDictionary Source="/Telerik.Windows.Themes.Office2013;component/Themes/Telerik.Windows.Controls.Docking.xaml" />
            </ResourceDictionary.MergedDictionaries>
            <Style TargetType="local:MainWindow" BasedOn="{StaticResource RadWindowStyle}" />
        </ResourceDictionary>
    </Application.Resources>

    Thus the Window should be visualized as expected. Please, give it a try and let us know if it worked for you.

    Hope this helps.

    Regards,
    Nasko
    Telerik
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Eugene
    Eugene avatar
    83 posts
    Member since:
    Jan 2016

    Posted 24 Mar in reply to Nasko Link to this post

    Thank you very much for your help, Nasko. Now MainWindow is visualized and my application works fine.
Back to Top