gpt4 book ai didi

wpf - 在 ConverterParameter 中使用字典中的字符串

转载 作者:行者123 更新时间:2023-12-04 21:55:18 24 4
gpt4 key购买 nike

我正在尝试使用 String来自字典:

<?xml version="1.0" encoding="utf-8" ?>
<Dictionary EnglishName="English" CultureName="English" Culture="en-US">
...
<Value Id="ButtonSuppressFieldInformation"
ToolTip="Remove field" Name="Remove field number "/>
...
</Dictionary>

在这个 ConverterParamter启用多种语言支持:
<Button>
...
<AutomationProperties.Name>
<MultiBinding
Converter="{StaticResource IndexedForAutomationId}"
ConverterParameter="{loc:Translate
Uid=ButtonSuppressFieldInformation, Default=Delete field}">
<Binding RelativeSource="{RelativeSource Self}" />
<Binding ElementName="MyContactDirectoryView"
Path="ListConditionToSearch" />
</MultiBinding >
</AutomationProperties.Name>
</Button>

但唯一显示的是数字( IndexedForAutomationId), string没有出现。

使用 string而不是 "{loc:Translate Uid=ButtonSuppressFieldInformation, Default=Delete field}"作品:
<MultiBinding Converter="{StaticResource IndexedForAutomationId}" 
ConverterParameter="Delete field">

显示 Delete field 0 .
loc:Translate有什么使用方法|作为转换器参数?

最佳答案

这个问题可能是由于很多事情造成的,更多的代码在这里真的会有所帮助。但是,我将从 Convert() 上的断点开始。 IndexedForAutomationId 的方法转换器到 1) 检查您是否从内部绑定(bind)中获得期望的值,以及 2) 检查转换器本身是否从字典中返回正确的字符串。

请务必查看这些关于 how to debug WPF bindings 的指南也是。

关于wpf - 在 ConverterParameter 中使用字典中的字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14955423/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com