Cannot access resource defined in app.xaml

Posted by DerKlaus on Stack Overflow See other posts from Stack Overflow or by DerKlaus
Published on 2010-03-21T14:05:18Z Indexed on 2010/03/21 14:11 UTC
Read the original article Hit count: 284

Filed under:
|
|

I am using Visual Studio 2010 RC1.

I define a resource "Brush2" in app.xaml_:

<Application x:Class="VideoThumbnails.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             StartupUri="MainWindow.xaml">
    <Application.Resources>

        <RadialGradientBrush x:Key="Brush2" RadiusX="1" RadiusY="1" GradientOrigin="0.3,0.3">
            <GradientStop Color="White" Offset="0"/>
            <GradientStop Color="#ffc0c0" Offset="1"/>
        </RadialGradientBrush>

    </Application.Resources>
</Application>

In my Mainwindow I am trying to use that resource:

...
<Border Margin="4,2" BorderBrush="Black" BorderThickness="2" CornerRadius="4"
        ToolTip="{Binding Path=FullPath}" HorizontalAlignment="Stretch"
        Background="{StaticResource Brush2}">
...

No matter what I do it always raises an exception at runtime (Resource not found). I changed build action without success.

How can I use resources defined in app.xaml?

© Stack Overflow or respective owner

Related posts about wpf

Related posts about resources