Monday, 10 January 2011

ResourceStrings in XAML

I needed to replace some hard-coded text in the xaml templates used in our Till Roll control. There was no easy route through to a general ViewModel that could expose some relevant properties to bind to.
In the end I chose to bind directly to the ResourceStrings resource using an x:Static
...
xmlns:local="clr-namespace:Sandstorm.PointOfSale.Modules.Tender.Resources"
...
<TextBlock Padding="20,0,0,0" Text="{Binding Source={x:Static local:ResourceStrings.V_Discount}, Mode=OneTime}" FontStyle="Italic"/>

No comments: