小编Der*_*aus的帖子

无法访问app.xaml中定义的资源

我正在使用Visual Studio 2010 RC1.

我在app.xaml_中定义了一个资源"Brush2":

<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>
Run Code Online (Sandbox Code Playgroud)

在我的Mainwindow中,我正在尝试使用该资源:

...
<Border Margin="4,2" BorderBrush="Black" BorderThickness="2" CornerRadius="4"
        ToolTip="{Binding Path=FullPath}" HorizontalAlignment="Stretch"
        Background="{StaticResource Brush2}">
...
Run Code Online (Sandbox Code Playgroud)

无论我做什么,它总是在运行时引发异常(未找到资源).我改变了构建操作但没有成功.

如何使用app.xaml中定义的资源?

wpf resources xaml

11
推荐指数
3
解决办法
1万
查看次数

标签 统计

resources ×1

wpf ×1

xaml ×1