I have a TextBlock which is bound to an Integer property of my model. The TextBlock int property increases its count from 0 to 99. I first show TextBlocks 0-9 in a ListView.
If there are more than 10 TextBlocks, I want the first 10 TextBlocks numbered 0-9 to show as 00, 01 , 02.. 09. I can use the string.Format method in WPF to achieve this behavior. But if there are fewer than 10 TextBlocks they should be numbered as 0, 1, 2 -- 9.
How can I achieve this behaviour? Can I use MultiBinding Converter? If yes, help me with a sample.
Here is the code:
<ListView ItemsSource= "{Binding}"> <!-- Binding to a collection which has the Tag Id property --> <Grid x:Name="TagNum_grid" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="1,3,0,0" Grid.Column="1" > <TextBlock x:Name="DefaultIDtextblock" Margin="1,0" Text="{Binding Path=TagID}" TextWrapping="Wrap" Foreground="#FFA0A0A0" /> </Grid> </ListView>