1

Is it possible to access a property value from the StringFormat binding property in XAML? I mean, this is my XAML:

<TextBox Name="costBlock" Grid.Row="4" Grid.Column="1" Margin="4" IsEnabled="False"
    Text="{Binding DataContext.CalculatedCost, Mode=OneWay, StringFormat={}{0} €}"></TextBox>

I need to replace the "€" symbol in the StringFormat bindingby the symbol of the selected currency, which is a property in a static class: Settings.SelectedCurrencySymbol.

How can I do it?

1
  • 1
    Use a MultiBinding with an IMultiValueConverter. Commented Sep 30, 2017 at 9:50

1 Answer 1

2

Thanks to Clemens reccommendation I found this solution:

<TextBlock Name="costBlock" Grid.Row="4" Grid.Column="1" Margin="4" 
    IsEnabled="False">
        <TextBlock.Text>
            <MultiBinding StringFormat="{}{0} {1}">
                <Binding Path="DataContext.CalculatedCost" />
                <Binding Path="(shared:Settings.SelectedCurrencySymbol)" />
            </MultiBinding>
        </TextBlock.Text>
    </TextBlock>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.