Bonjour,
J4ai une fenetre à laquelle j'ai ajouté la possibilité d'ouvrir d'une fenetre "A propos". J'ai pris exemple sur une appli ou cela fonctionne.
Chez moi, j'ai une erreur qui bloque tout quand j'ouvre cette fenetre "About".
Une exception non gérée du type 'System.Windows.Markup.XamlParseException' s'est produite dans PresentationFramework.dll
Informations supplémentaires*: 'La valeur fournie sur 'System.Windows.Markup.StaticExtension' a levé une exception.' numéro de ligne '7' et position de ligne '9'.
Le code de ma fenetre About qui semble etre la cause de l'erreur:
Code xaml : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57 <Window x:Class="MyProject.Views.AboutWindowView" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:c="clr-namespace:MyProject.Converters" xmlns:p="clr-namespace:MyProject.Properties" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" ResizeMode="NoResize" SizeToContent="WidthAndHeight" Title="{x:Static p:Resources.AboutTitle}" WindowStartupLocation="CenterOwner"> <Window.Resources> <c:StringPathToImageSourceConverter x:Key="ImageConverter" /> </Window.Resources> <Grid Height="200" Margin="5" Width="400"> <Grid.RowDefinitions> <RowDefinition Height="0.30*" /> <RowDefinition Height="0.60*" /> <RowDefinition Height="0.10*" /> </Grid.RowDefinitions> <StackPanel Margin="10" Orientation="Horizontal"> <Image x:Name="_image" Margin="2" Source="{Binding Source={x:Static p:Resources.AboutImage}, Converter={StaticResource ImageConverter}}" /> <TextBlock FontSize="16" FontWeight="Bold" Text="{x:Static p:Resources.CompanyName}"> <TextBlock.Effect> <DropShadowEffect /> </TextBlock.Effect> </TextBlock> </StackPanel> <StackPanel Grid.Row="1" Margin="10"> <TextBlock FontSize="12" FontWeight="Normal" Text="{x:Static p:Resources.ApplicationName}" /> <TextBlock /> <TextBlock FontSize="12" FontWeight="Normal" Text="Version 1.0" /> <TextBlock /> <TextBlock FontSize="12" FontWeight="Normal" Text="{x:Static p:Resources.Copyright}" /> </StackPanel> <Grid Grid.Row="2"> <Button Click="ok_Click" Content="{x:Static p:Resources.Ok}" Height="20" HorizontalAlignment="Right" IsDefault="True" Name="ok" VerticalAlignment="Bottom" Width="80" /> </Grid> </Grid> </Window>
Le designer m'affiche la fenetre comme il faut sans probleme. Ca pete toujours pour la meme raison a la 2° ligne (a la 3° si je commente la 2°):
Si je vire les 4 lignes du xaml, ca pete de la meme maniere a l'equivalent de la ligne 23 (l'image).
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3 AboutWindowView about = new AboutWindowView(); about.Owner = Application.Current.MainWindow; about.ShowDialog();
(pour info je m'inspire du projet workOrders du cours microsoft pour WPF 10262A).
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4 ResizeMode="NoResize" SizeToContent="WidthAndHeight" Title="{x:Static p:Resources.AboutTitle}" WindowStartupLocation="CenterOwner"
Si quelqu'un a une idée de ce qui pourrait provoquer cette erreur
Merci beaucoup,
Inter'
Partager