This is a mirror of official site: http://jasper-net.blogspot.com/

WPF Quiz #1 – Resources

| Monday, January 10, 2011
Having the following WPF code snippets:

<Application x:Class="Quiz1.App"
   xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation
   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
   <Application.Resources>
       <SolidColorBrush x:Key="BackgroundBrush" Color="Red" />
   </Application.Resources>
</Application>


public partial class App : Application
{
   private readonly Window _mainWindow = new MainWindow();

   protected override void OnStartup(StartupEventArgs e)
   {
       _mainWindow.Show();
       base.OnStartup(e);
   }
}


<Window x:Class="Quiz1.MainWindow"
   xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation
   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
       Title="MainWindow" Height="350" Width="525">
   <Grid Background="{StaticResource BackgroundBrush}" />    
</Window>


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

Which one of the following statements is true?

a. Running the application, the grid background will be rendered Red.
b. Running the application, the grid background won't be rendered.
c. Running the application, an exception will be thrown.
d. The grid background won't be rendered at design time.

Read more: Essential WPF and Young Brothers

Posted via email from .NET Info