For example i have smth like this
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace:System;assembly=mscorlib">
<sys:String x:Key="USERNAME_AUTH_CONTENT">User auth success</sys:String>
</ResourceDictionary>
and in code behind, sometimes, I use this
var text = findRes("USERNAME_AUTH_CONTENT");
Is it possible to make smth like this:
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace:System;assembly=mscorlib">
<sys:String x:Key="USERNAME_AUTH_CONTENT">User %username auth success</sys:String>
</ResourceDictionary>
and at codebehind
var text = findRes("USERNAME_AUTH_CONTENT", "here is i want to paste username");
in the end I want see this: 'User AwesomeUserName auth success'
In c++ I can use %d for string. What about c# and resources?
C# uses
{0},{1}, etc, placeholders for string formatting.declare xaml resource with a placeholder
and use
String.Formatto apply formatting:note also that you can use format string directly from xaml:
(
Source='AwesomeUserName'is just an example, if you have a view model, then useBinding Path=SomeProperty)