wpf '在'System.Windows.Baml2006.TypeConverterMarkupExtension'上提供值抛出异常。行号“49”和行位置“38”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22736582/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 11:23:20  来源:igfitidea点击:

'Provide value on 'System.Windows.Baml2006.TypeConverterMarkupExtension' threw an exception.' Line number '49' and line position '38'

c#wpf

提问by Asercu

I am making my first wpf application which now just implements a "floor" with a texture, viewed from above. when running I get this exception:

我正在制作我的第一个 wpf 应用程序,它现在只是实现了一个带有纹理的“地板”,从上面看。运行时出现此异常:

Provide value on System.Windows.Baml2006.TypeConverterMarkupExtension' threw an exception.' Line number '49' and line position '38'

在 System.Windows.Baml2006.TypeConverterMarkupExtension 上提供值“抛出异常”。行号“49”和行位置“38”

The line they talk about is

他们谈论的线路是

<ImageBrush ImageSource="/wood1_1000X1000.jpg" />.

I also tried with a png extension. The image has a resolution of 1000 x 1000.

我也尝试过使用 png 扩展名。图像的分辨率为 1000 x 1000。

回答by vivat pisces

Assuming the image is:

假设图像是:

  • Included in your project
  • It's in a folder named "Images"
  • The build action for the image is set to "Resource" (should be the default)
  • 包含在您的项目中
  • 它位于名为“Images”的文件夹中
  • 图像的构建操作设置为“资源”(应该是默认值)

You can reference it like this:

您可以像这样引用它:

<ImageBrush ImageSource=
   "pack://application:,,,/YourProjectName;component/Images/wood1_1000X1000.jpg";

回答by Mathivanan KP

In my case, I had foreground color as 282828 for a checkbox. I changed it as #282828. Its fixed the issue.

就我而言,复选框的前景色为 282828。我将其更改为#282828。它解决了这个问题。