Problem with BussyIndicator...

2 posts, 0 answers
  1. Tomas
    Tomas avatar
    21 posts
    Member since:
    Sep 2010

    Posted 20 Jul 2011 Link to this post

    Hallo,
    we have a serious problem with BussyIndicator component with the combination of theme "Metro". We're using bussy indicator inside splash window, which is opened during the app start up in the separate thread. Folowing exception is raised:

    ----------- Exception
       v System.Windows.DependencyObject.GetValue(DependencyProperty dp)
       v Telerik.Windows.Controls.MetroColorPalette.get_BasicColor() v c:\TB\102\WPF_Scrum\Current_HotFix\Sources\Development\Core\Controls\Theming\MetroColorPalette.cs:line 39
       v Telerik.Windows.Controls.MetroColors.get_BasicColor() v c:\TB\102\WPF_Scrum\Current_HotFix\Sources\Development\Core\Controls\Theming\MetroColors.cs:line 62
    -----------

    The xaml code of splash window is:
    <Window x:Class="PFCP.Infrastructure.Client.Shell.MVVM.Splash"
            WindowStartupLocation="CenterOwner" 
            WindowStyle="None" 
            Height="240" Width="420"
            BorderBrush="Transparent" 
            BorderThickness="0" 
            ShowInTaskbar="False" 
            AllowsTransparency="True"
            Background="Transparent"
            ResizeMode="NoResize" 
            Icon="{x:Null}"
            >
      
        <Window.Resources>
        </Window.Resources>
      
        <telerik:RadBusyIndicator x:Name="_busyIndicator" IsBusy="True" BusyContent="{Binding BusyContent}">
      
            <Border HorizontalAlignment="Right" Margin="0" VerticalAlignment="Bottom" 
                    Background="Goldenrod" BorderThickness="1" SnapsToDevicePixels="True" BorderBrush="Gray"
                    CornerRadius="8">
                <Grid>
                    <StackPanel>
                    <Label Margin="4" Content="{Binding SplashTitle}" FontSize="24" HorizontalContentAlignment="Left" VerticalContentAlignment="Top"
                           Foreground="Black">
                        <Label.BitmapEffect>
                            <OuterGlowBitmapEffect GlowSize="15" />
                        </Label.BitmapEffect
                    </Label>
                        <Label Margin="15,0,0,0" Content="{Binding VersionInfo}" HorizontalContentAlignment="Left" VerticalContentAlignment="Top" Foreground="Black" />
                    </StackPanel>
      
                    <Image x:Name="image" Source="..\..\Images\SplashBackground.png"  VerticalAlignment="Stretch" HorizontalAlignment="Stretch"  
                       SnapsToDevicePixels="True" RenderTransformOrigin="0.5,0.5">
                        <Image.RenderTransform>
                            <TransformGroup>
                                <ScaleTransform/>
                                <SkewTransform/>
                                <RotateTransform/>
                                <TranslateTransform/>
                            </TransformGroup>
                        </Image.RenderTransform>
                    </Image>
                </Grid>
            </Border>
      
        </telerik:RadBusyIndicator>
    </Window>

    the code for display of the splash is:

    /// <summary>
    /// Helper class to show or close given splash screen
    /// </summary>
    internal class SplashScreenService : ISplashScreenService
    {
        private Splash                  _splash = null;
        private SplashViewModel         _splashViewModel = null;
        /// <summary>
        /// Constructor
        /// </summary>
        public SplashScreenService(IContainer dependencyContainer)
        {
        }
        /// <summary>
        /// Set dynamic text in the splash
        /// </summary>
        /// <param name="message"></param>
        public void SetSplashText(string message)
        {
            if (this._splashViewModel != null)
            {
                this._splashViewModel.BusyContent = message;
            }
        }
        /// <summary>
        /// Show the splash screen
        /// </summary>
        public void ShowSplash(Window ownerWindow, string splashTitle, string versionInfo, string splashText)
        {
            if (this._splash != null)
            {
                this._splash.Dispatcher.BeginInvoke(new Action(() =>
                {
                    this._splash.Close();
                }));
            }
            System.Threading.Thread thread = new System.Threading.Thread(new System.Threading.ParameterizedThreadStart((object oParam) =>
            {
                SplashStartInfo splashStartInfo = oParam as SplashStartInfo;
                Debug.Assert(splashStartInfo != null);
                this._splashViewModel = new SplashViewModel();
                Splash splashView = new Splash(_splashViewModel);
                this._splashViewModel.SplashTitle = splashStartInfo.SplashTitle;
                this._splashViewModel.VersionInfo = splashStartInfo.VersionInfo;
                this._splashViewModel.BusyContent = splashStartInfo.SplashText;
                if (splashStartInfo.OwnerHandle != null)
                {
                    WindowInteropHelper winInteropHelper = new WindowInteropHelper(splashView);
                    winInteropHelper.Owner = splashStartInfo.OwnerHandle;
                }
                this._splash = splashView;
                this._splash.ShowDialog();
            }));
            thread.SetApartmentState(System.Threading.ApartmentState.STA);
            thread.Start(new SplashStartInfo(ownerWindow, splashTitle, versionInfo, splashText));
        }
        /// <summary>
        /// Close the splash screen
        /// </summary>
        public void CloseSplash()
        {
            if (this._splash != null)
            {
                this._splash.Dispatcher.BeginInvoke(new Action(() =>
                {
                    this._splash.Close();
                }));
                if (this._splash is IDisposable)
                {
                    (this._splash as IDisposable).Dispose();
                }
            }
        }
    }
    #region helper class SPlashStartInfo...
    /// <summary>
    /// Helper class for start of the splash screen in the separate thread
    /// </summary>
    class SplashStartInfo
    {
        public SplashStartInfo(Window ownerWindow, string splashTitle, string versionInfo, string splashText)
        {
            this.SplashTitle = splashTitle;
            this.VersionInfo = versionInfo;
            this.SplashText = splashText;
            this.OwnerHandle = new WindowInteropHelper(ownerWindow).Handle;
        }
        public string SplashTitle { get; set; }
        public string SplashText { get; set; }
        public string VersionInfo { get; set; }
        public IntPtr OwnerHandle { get; set; }
    }

     If I set in the App.OnStartup() method "StyleManager.ApplicationTheme = new MetroTheme();" the exception is raised, when I use any other theme, application starts without any problems.. Thanks for any solution.
    Tomas.
  2. Dani
    Admin
    Dani avatar
    848 posts

    Posted 21 Jul 2011 Link to this post

    Hello Tomas,

    Thank you for describing the issue.

    We are aware of this behavior related to the Metro theme. The Metro theme in WPF is not supported in multi-threaded scenarios due to the way it uses its static brushes.

    This issue will be fixed for the SP1 release, which will be in September. We are sorry if using the theme  causes inconvenience at the moment.

    Greetings,
    Dani
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Back to Top