简体   繁体   English

System.Windows.Baml2006.TypeConverterMarkupExtension

[英]System.Windows.Baml2006.TypeConverterMarkupExtension

Hello I do have a Problem quite a lot of people seem to have but i tried the suggested Solutions and they haven't worked. 您好,我确实有一个问题,似乎很多人都遇到了问题,但是我尝试了建议的解决方案,但他们没有起作用。 I have this Code that always throws a exception (Message: "Provide value on 'System.Windows.Baml2006.TypeConverterMarkupExtension' threw an exception") at the Window.InitializeComponent() Methode. 我有此代码,总是在Window.InitializeComponent()方法上引发异常(消息:“在'System.Windows.Baml2006.TypeConverterMarkupExtension'上提供值引发了异常”)。 Here is My Xaml Code: 这是我的Xaml代码:

<Window x:Class="SimpleMoving.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Name="SquareFighter" Height="392" Width="621" KeyDown="Window_KeyDown" KeyUp="Window_KeyUp" ResizeMode="CanMinimize">
    <Canvas Name="MyCanvas">
        <Rectangle Name="Box" Height="60" Canvas.Left="17" Stroke="Black" Canvas.Top="172" Width="30">
            <Rectangle.Fill>
                <ImageBrush ImageSource="pack://application:,,,/Resources/Peanut.png"/>
            </Rectangle.Fill>
        </Rectangle>
        <Rectangle Name="Rec1" Height="30" Canvas.Left="908" Stroke="Black" Canvas.Top="50" Width="30">
            <Rectangle.Fill>
                <ImageBrush ImageSource="pack://application:,,,/Resources/Rock.png"/>
            </Rectangle.Fill>
        </Rectangle>
        <Rectangle Height="30" Canvas.Left="908" Stroke="Black" Canvas.Top="110" Width="30">
            <Rectangle.Fill>
                <ImageBrush ImageSource="pack://application:,,,/Resources/Rock.png"/>
            </Rectangle.Fill>
        </Rectangle>
        <Rectangle Height="30" Canvas.Left="908" Stroke="Black" Canvas.Top="169" Width="30">
            <Rectangle.Fill>
                <ImageBrush ImageSource="pack://application:,,,/Resources/Rock.png"/>
            </Rectangle.Fill>
        </Rectangle>
        <Rectangle Height="30" Canvas.Left="908" Stroke="Black" Canvas.Top="229" Width="30">
            <Rectangle.Fill>
                <ImageBrush ImageSource="pack://application:,,,/Resources/Rock.png"/>
            </Rectangle.Fill>
        </Rectangle>
        <Rectangle Height="30" Canvas.Left="908" Stroke="Black" Canvas.Top="289" Width="30">
            <Rectangle.Fill>
                <ImageBrush ImageSource="pack://application:,,,/Resources/Rock.png"/>
            </Rectangle.Fill>
        </Rectangle>
        <Label Name="LevelLabel" Content="Level: 1" Canvas.Left="54" Canvas.Top="10" Height="38" Width="164" FontSize="20"/>
        <Label Content="Shoot the squares back using WSDA!" Canvas.Left="180" Width="290" FontSize="16"/>
    </Canvas>
</Window>

I don't know what to do. 我不知道该怎么办。 I hope you can help. 希望您能提供帮助。

Most likely you don't have images located under Resources folder. 您很可能没有在Resources文件夹下的图像。

Make sure following things holds valid for both images (Rock.png and Peanut.png) used in your XAML: 确保以下内容对XAML中使用的两个图像(Rock.png和Peanut.png)都有效:

  1. Image is added in project under Resources folder in same project. 图像已added in project under Resources folder到同一项目中“ added in project under Resources folder项目中。
  2. Build Action for image is set to Resource . 图像的Build Action设置为Resource

Also, you can try using more verbose Pack URI definition: 另外,您可以尝试使用更多详细的Pack URI定义:

"pack://application:,,,/SimpleMoving;component/Resources/Peanut.png" and "pack://application:,,,/SimpleMoving;component/Resources/Rock.png" where SimpleMoving is name of your assembly. "pack://application:,,,/SimpleMoving;component/Resources/Peanut.png""pack://application:,,,/SimpleMoving;component/Resources/Rock.png" ,其中SimpleMoving是程序集的名称。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在“ System.Windows.Baml2006.TypeConverterMarkupExtension”上提供值引发异常 - Provide value on 'System.Windows.Baml2006.TypeConverterMarkupExtension' threw an exception 如何解决此错误:“在&#39;System.Windows.Baml2006.TypeConverterMarkupExtension&#39;上提供值” - How do I fix this error : 'Provide value on 'System.Windows.Baml2006.TypeConverterMarkupExtension' 使用触发器更改图像获取System.Windows.Baml2006.TypeConverterMarkupExtension错误 - Change an image using triggers getting System.Windows.Baml2006.TypeConverterMarkupExtension error System.Windows.Baml2006.TypeConverterMarkupExtension&#39;抛出异常。&#39; 行号&#39;6&#39;和行位置&#39;10 - System.Windows.Baml2006.TypeConverterMarkupExtension' threw an exception.' Line number '6' and line position '10 '在 'System.Windows.Baml2006.TypeConverterMarkupExtension' 上提供值引发异常。 - 'Provide value on 'System.Windows.Baml2006.TypeConverterMarkupExtension' threw an exception.' &#39;为&#39;System.Windows.Baml2006.TypeConverterMarkupExtension&#39;提供价值,引发了一个异常。 行号&#39;49&#39;和行位置&#39;38&#39; - 'Provide value on 'System.Windows.Baml2006.TypeConverterMarkupExtension' threw an exception.' Line number '49' and line position '38' 错误System.Windows.Baml2006.TypeConverterMerkupExtension。 会是什么呢? - error System.Windows.Baml2006.TypeConverterMerkupExtension. What could it be? 异常:查找主题\\ generic.baml时出现System.Resources.MissingManifestResourceException - Exception: System.Resources.MissingManifestResourceException while looking for themes\generic.baml 使用Baml管理本地化 - Manage localization with Baml 将Xaml转换为Baml - Convert Xaml to Baml
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM