在 Pack URI 数据绑定中转义逗号(简单问题)
我将 Image 控件绑定到运行时设置的值,但我想将 FallbackValue 设置为名为“checkerboard.png”的资源。
由于转换器不适用于 FallbackValues,我需要使用 Pack 表示法,这给我留下了以下 XAML:
<Image x:Name="imgButton"
Height="{Binding Path=Height}"
Width="{Binding Path=Width}"
Stretch="Fill"
Source="{Binding Path=Image, FallbackValue=pack://application:,,,/checkerboard.png}"/>
但是当我去构建时,编译器在 FallbackValue 内的逗号出现问题,给出以下错误:
标记扩展要求名称和值之间有一个“=”,构造函数参数和名称/值对之间有一个“,”。参数“Path=Image, FallbackValue=pack://application:,,,/checkerboard.png}”无效。
是否有转义字符可以用来强制编译器接受逗号,或者还有另一种方法可以解决这个问题吗?
I'm binding an Image control to a value set at runtime, but I want to set the FallbackValue to a resource named "checkerboard.png".
As Converters aren't applied to FallbackValues I need to use the Pack notation, which leaves me with the following XAML:
<Image x:Name="imgButton"
Height="{Binding Path=Height}"
Width="{Binding Path=Width}"
Stretch="Fill"
Source="{Binding Path=Image, FallbackValue=pack://application:,,,/checkerboard.png}"/>
But when I go to build, the compiler has issues with the commas inside the fallbackvalue, giving the following error:
Markup extensions require a single '=' between name and value, and a single ',' between constructor parameters and name/value pairs. The arguments ' Path=Image, FallbackValue=pack://application:,,,/checkerboard.png}' are not valid.
Is there an escape character I can use to force the compiler to accept the commas, or is there another way around this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试将 FallbackValue 放在单引号内
Try putting the FallbackValue within single quotes