System.Windows.Baml2006.TypeConverterMarkupExtension'抛出异常。'行号'6'和行位置'10

时间:2013-08-01 17:29:54

标签: c# wpf wpf-controls

我为wpf项目添加了一个Image资源:

right-click on the Project -> Properties -> Resources -> Images -> From Existing -> ClientBackGround.png

我把它作为主窗口的背景:

<Window x:Class="Illuminate_AutoPatcher.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Width="1000" Height="750" ResizeMode="NoResize" WindowStyle="None" WindowStartupLocation="CenterScreen">
    <Window.Background>
        <ImageBrush ImageSource="pack://siteoforigin:,,,/Resources/ClientBackground.png"/>
    </Window.Background>
    <Grid>
        <Button Content="" HorizontalAlignment="Left" VerticalAlignment="Top" Width="224" Margin="766,613,0,0" Height="124" >
        </Button>
    </Grid>
</Window>

但它没有工作它继续抛出这个恼人的错误System.Windows.Baml2006.TypeConverterMarkupExtension' threw an exception.' Line number '6' and line position '10,我应该如何解决它,所以我使用与项目一起构建的静态资源?

1 个答案:

答案 0 :(得分:8)

@HighCore是对的,使用应用程序解决了给定方案中的问题

    <ImageBrush ImageSource="pack://application:,,,/Resources/ClientBackground.png"/>

您仍然可以使用 siteoforigin 。为此,您必须设置图像属性

复制到输出目录改为“ 始终复制

MSDN Link

相关问题