J'ai un projet WPF avec un TextBlock avec et de liaison à un certain nombre comme "0009012"
mais je veux montrer que 9012
ou pour 0881012
doivent se montrer 881012
.TextBlock StringFormat Garniture Zéros
Existe-t-il un moyen avec StringFormat ou dois-je écrire un convertisseur pour cela?
Voici mon code:
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<TextBlock Text="{Binding Test}" StringFormat={}{????}/>
</Grid>
</Window>
using System.Windows;
namespace WpfApplication1
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public string Test { get; set; }
public MainWindow()
{
Test = "00090012";
InitializeComponent();
DataContext = this;
}
}
}
'" 00090012 "' n'est pas un nombre. c'est une chaîne. il est affiché tel quel. – ASh
Pourriez-vous essayer 'StringFormat = {} {0: 0}}' 'et voir ce qui est affiché? –
*" Y at-il un moyen avec StringFormat ou dois-je écrire un convertisseur pour cela? "* Vous devez écrire un convertisseur –