Search code examples
c#wpfdata-bindingwpfdatagrid

Add Additional Character in WPF Data Bind


I'm new in WPF application and i have a question.

Is it possible to add additional character for each row bind from database?

I've drag and drop dataset to create a list of datagrid. It will automatically generate codes for data binding. I want to add '%' symbol on the back of {Percentage} data.

<DataGridTextColumn x:Name="percentageColumn" Binding="{Percentage}" Header="Percentage" Width="SizeToHeader"/>

This example kinda confuse me a bit.


Solution

  • The example answers it perfectly. Just use stringformat with the binding.

    <DataGridTextColumn x:Name="percentageColumn" Binding="{Percentage,StringFormat={}{0}%}" Header="Percentage" Width="SizeToHeader"/>