Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/325.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用valueconverter时,图像不显示为按钮的背景_C#_Silverlight_Xaml_Windows Phone 8_Windows Phone - Fatal编程技术网

C# 使用valueconverter时,图像不显示为按钮的背景

C# 使用valueconverter时,图像不显示为按钮的背景,c#,silverlight,xaml,windows-phone-8,windows-phone,C#,Silverlight,Xaml,Windows Phone 8,Windows Phone,我试图使用ValueConverter设置图像的背景,当我直接在XAML中设置背景图像时,它会显示,但使用转换器时,它不会显示 用于创建按钮的我的XAML代码: <Button x:Name="image" Grid.Column="2" VerticalAlignment="Center" Margin="0, 0, -1, 0" Width="100" Height="100" Click="image_CLick"> <Button.Background>

我试图使用ValueConverter设置图像的背景,当我直接在XAML中设置背景图像时,它会显示,但使用转换器时,它不会显示

用于创建按钮的我的XAML代码:

<Button x:Name="image" Grid.Column="2" VerticalAlignment="Center" Margin="0, 0, -1, 0" Width="100" Height="100" Click="image_CLick">
   <Button.Background>
      <ImageBrush ImageSource="{Binding Path=isSaved, Converter={StaticResource BoolImageConverter}}"/>
   </Button.Background>
</Button>
如果我将返回类型更改为位图图像,则此ValueConverter适用于普通图像元素


有什么想法吗?

您是否尝试将路径更改为:

@"Images\ThumbSelected@2x.png"


我假设您已经尝试过明显的方法,例如从Uri路径中删除前导“/”并将“/”更改为“\”?@TylerD87 Visual Studio声明“\”是无法识别的转义序列。请将路径更改为@”图像\ThumbSelected@2x.png". @before符号告诉编译器忽略转义字符。或者,您可以将其写为“图像”\\ThumbSelected@2x.png“@TylerD87真是太棒了,真管用!你可以把它作为回答,这样我就可以接受了。这是正确的答案。干杯,我做到了。
@"Images\ThumbSelected@2x.png"
@"Images\thumb.png"