Background color in Modal Window

4 posts, 1 answers
  1. Ben Hayat
    Ben Hayat avatar
    892 posts
    Member since:
    May 2008

    Posted 28 Nov 2011 Link to this post

    Hello Team;

    When we display a modal Window, the background turns to a "Purple" color. Is it possible for us to change that color? If not, could you change it to a Gray color that is more industry STD?

    Thanks!
  2. Answer
    Dani
    Admin
    Dani avatar
    848 posts

    Posted 29 Nov 2011 Link to this post

    Hello Ben,

    The default modal background for RadWindow dialogs is the following brush:
    <LinearGradientBrush x:Key="WindowModalBackground" EndPoint="0.5,1" StartPoint="0.5,0">
            <GradientStop Color="#E5000000" />
            <GradientStop Color="#4C000000" Offset="0.5" />
            <GradientStop Color="#E5000000" Offset="1" />
        </LinearGradientBrush>

    You can easily change that by setting the ModalBackground property of RadWindow. For example:
    <LinearGradientBrush x:Key="WindowModalBackground" EndPoint="0.5,1" MappingMode="RelativeToBoundingBox" StartPoint="0.5,0">
        <GradientStop Color="#CC012A7C" Offset="0.987"/>
        <GradientStop Color="#CC84ABF9"/>
    </LinearGradientBrush>      
          
    <Style x:Key="RadWindowStyle1" TargetType="telerik:RadWindow">          
        <Setter Property="ModalBackground" Value="{StaticResource WindowModalBackground}"/> 
    </Style>

    I hope this will help.

    Greetings,
    Dani
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
  3. DevCraft banner
  4. Ben Hayat
    Ben Hayat avatar
    892 posts
    Member since:
    May 2008

    Posted 29 Nov 2011 Link to this post

    And is best to include it in App.xaml to have global effect?
  5. Dani
    Admin
    Dani avatar
    848 posts

    Posted 30 Nov 2011 Link to this post

    Hello Ben ,

    Yes, if you place the style in App.xaml it will be accessible from all RadWindows you may have in your application. Yet the style must be explicit, i.e. with an x:Key. You can then apply it to any RadWindow in your application. For example:
    private void RadButton_Click(object sender, RoutedEventArgs e)
            {
                MyWindow w = new MyWindow();
      
                w.Height = 300;
                w.Width = 600;
                w.Style = Application.Current.Resources["MyStyle"] as Style;
      
                w.WindowStartupLocation = Telerik.Windows.Controls.WindowStartupLocation.CenterScreen;
                w.ShowDialog();
            }
     
    I hope this helps.

    Greetings,
    Dani
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
Back to Top