Mualig
Mualig

Reputation: 1444

Using String from a dictionary in a ConverterParameter

I'm trying to use a String from a dictionary:

<?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>

In this ConverterParamter to enable multiple langages support:

<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>

But the only thing shown is the number (IndexedForAutomationId), the string does not appear.

Using a string instead of "{loc:Translate Uid=ButtonSuppressFieldInformation, Default=Delete field}" works:

<MultiBinding Converter="{StaticResource IndexedForAutomationId}" 
              ConverterParameter="Delete field">

Displays Delete field 0.

What is the way to use loc:Translate as a ConverterParameter?

Upvotes: 4

Views: 580

Answers (1)

Efran Cobisi
Efran Cobisi

Reputation: 6474

This issue could be due to a lot of things and some more code would really help here. I would start, however, with a breakpoint on the Convert() method of the IndexedForAutomationId converter to 1) check if you get the values your are expecting from the inner bindings and 2) check if the converter itself is returning the right string from the dictionary.

Please make sure to review these guidelines about how to debug WPF bindings as well.

Upvotes: 1

Related Questions