wpf System.Windows.Baml2006.TypeConverterMarkupExtension'抛出异常。行号“6”和行位置“10”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18000737/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
System.Windows.Baml2006.TypeConverterMarkupExtension' threw an exception.' Line number '6' and line position '10
提问by Abanoub
I have add an Image resource for the wpf project am making by:
我为正在制作的 wpf 项目添加了一个图像资源:
right-click on the Project -> Properties -> Resources -> Images -> From Existing -> ClientBackGround.png
right-click on the Project -> Properties -> Resources -> Images -> From Existing -> ClientBackGround.png
and I made it background for the main window :
我把它作为主窗口的背景:
<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>
but it's not working it's keep throwing this anoying error System.Windows.Baml2006.TypeConverterMarkupExtension' threw an exception.' Line number '6' and line position '10, how I supposed to fix it, so I use static resources that's build with the project?
但它不起作用它一直抛出这个令人讨厌的错误System.Windows.Baml2006.TypeConverterMarkupExtension' threw an exception.' Line number '6' and line position '10,我应该如何修复它,所以我使用与项目一起构建的静态资源?
回答by Uttam K C
@HighCore is right, using applicationsolves your issue in the given scenario
@HighCore 是对的,在给定的场景中使用应用程序可以解决您的问题
<ImageBrush ImageSource="pack://application:,,,/Resources/ClientBackground.png"/>
You still can use siteoforigin. For that you have to set the image property
您仍然可以使用siteoforigin。为此,您必须设置图像属性
Copy to Output Directoryto "Copy always"
复制到输出目录到“始终复制”

