[Solved] How to convert a string to formatted text C# [closed]


You can always use the normal C# tools to do this.

However, if the entire purpose is to make a nice string for binding, you may be able to use the binding’s StringFormat directly.

For example, you can have a TextBlock like so:

<TextBlock>
    <TextBlock.Text>
      <MultiBinding  StringFormat="{}{0} at distance of {1}m.">
        <Binding Path="User"/>
        <Binding Path="Distance"/>
      </MultiBinding>
    </TextBlock.Text>
</TextBlock>

This will format the text based off the “User” and “Distance” bound values.

solved How to convert a string to formatted text C# [closed]