Windows Phone xaml non valide ?
Bonjour,
Je suis entrain de développer une application WP en C#, mais j'ai un prb :
Visual studio me dit "XAML non valide" et me souligne tout le pavé ListBox en bleu..
Cela n’empêche pas la compilation et l'application fonctionne, mais c'est pas très propre :(
Le problème vient du convertisseur dans la source de l'image car quand je la retire tout rentre dans l'ordre.
Mais je voie pas mon erreur :O
La partie xaml :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
<ListBox.ItemTemplate>
<DataTemplate>
<Border Background="#FFDEDEDE" CornerRadius="10" Margin="10">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Width="450">
<TextBlock HorizontalAlignment="Center" Text="{Binding NumIT}" FontSize="30" Foreground="Blue" Margin="10 10 200 10" />
<Image x:Name="MonImage" Source="{Binding Etat, Converter={StaticResource EtatConverter}}" Width="48" Height="48" />
</StackPanel>
</Border>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox> |
Le converter :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
public class EtatConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value.ToString() == "EnCours")
return new Uri("Assets/Images/EnCours.png", UriKind.Relative);
else if (value.ToString() == "Fini")
return new Uri("Assets/Images/Fini.png", UriKind.Relative);
return 0;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException(); //doing one-way binding so this is not required.
}
} |
Merci :)