Bonjour
Encore moi qui patauge dans ma découverte de dev sous windows8
Je me suis inspiré du code de ce tuto (plutôt bien fait), pour faire un écran de chargement avant l'affichage d'images:
Première question, dans ces tutos, il est dit que les classes dans Commom étaient automatiquement générées par visual studio (comme LayoutAwarePage). Dans Common je n'ai qu'un seul fichier StandardStyles.xaml. Pourquoi?
Deuxième point,
dans mon application je commence donc par lire dans un fichier un certain nombre d'information (des offset d'image). Pendant ce chargement, j'affiche un petit écran de chargement (comme dans le tuto) :
Jusque là, pas de problème.
Code c# : 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
58
59
60
61
62
63
64
65
66
67 public sealed partial class ExtendedSplachScreen : UserControl { private SplashScreen splashScreen; // Variable to hold the splash screen object. private MZHandler mzHandler = null; public ExtendedSplachScreen(SplashScreen splash, MZHandler mozzoHandeler) { this.splashScreen = splash; this.mzHandler = mozzoHandeler; this.InitializeComponent(); this.extendedSplashImage.SetValue(Canvas.LeftProperty, this.splashScreen.ImageLocation.X); this.extendedSplashImage.SetValue(Canvas.TopProperty, this.splashScreen.ImageLocation.Y); this.extendedSplashImage.Height = this.splashScreen.ImageLocation.Height; this.extendedSplashImage.Width = this.splashScreen.ImageLocation.Width; AttachHandler(); ExecuteParsing(); } private void ExecuteParsing() { if (this.mzHandler != null) { this.mzHandler.ParseMZFileAsyncr(); } } internal void splashScreen_Dismissed(SplashScreen sender, object args) { [...] } void mzHandlerPageLoadProgress(object sender, MZHandler.PageLoadEnventArgs e) { txtLoading.Text = "Chargement page " + e.nbPage; } void mzHandlerPagesLoaded(object sender, MZHandler.PageLoadEnventArgs e) { Navigate(this.mzHandler); } void AttachHandler() { this.splashScreen.Dismissed += splashScreen_Dismissed; this.mzHandler.LoadMZFileProgress += mzHandlerPageLoadProgress; this.mzHandler.PagesLoaded += mzHandlerPagesLoaded; } void DetachHandler() { [...] } void Navigate(MZHandler mzHandler) { DetachHandler(); var rootFrame = new Frame(); rootFrame.Navigate(typeof(MainPage), mzHandler); // Place the frame in the current Window and ensure that it is active Window.Current.Content = rootFrame; Window.Current.Activate(); } }
C'est au moment d'afficher la page "MainPage" que ca ne va pas. 9 fois sur 10, j'ai un écran noir . Je suis quasiment sur que mon objet MainPage est bien construit (dans une version précédente, je l'affichais sans problème). J'ai passé la journée à chercher d'ou ca pouvais venir (break pont, pas à pas...), je ne vois pas pourquoi j'ai un écran noir et pas ma page.
Voici le xaml de mainpage:(Remarquer la forte ressemblance avec mon topic précédent
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
58
59
60
61
62
63
64
65 <Page x:Class="MZReader01.MainPage" IsTabStop="false" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:MZReader01" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"> <!-- Ressource de la page --> <Page.Resources> <!-- Style pour le bouton zoom --> <Style x:Key="ZoomAppBarButtonStyle" TargetType="Button" BasedOn="{StaticResource AppBarButtonStyle}"> <Setter Property="AutomationProperties.AutomationId" Value="ZoomAppBarButton"/> <Setter Property="AutomationProperties.Name" Value="Zoom"/> <Setter Property="Content" Value=""/> </Style> <!-- Template pour l'affichage d'une page avec l'image de la page (Thumbnail/Mini) et un texte --> <DataTemplate x:Key="PageTemplate"> <Border Background="Orange"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="*"/> <ColumnDefinition Width="300"/> </Grid.ColumnDefinitions> <Grid Grid.Column="0"> <StackPanel x:Name="ImagePanel" Height="669" Margin="20,10,10,0" VerticalAlignment="Top" Width="1036" HorizontalAlignment="Center" Orientation="Horizontal"> <Image x:Name="ImageView" Source="{Binding ImageData}" Margin="0,10,10,10" HorizontalAlignment="Center" VerticalAlignment="Bottom"/> </StackPanel> </Grid> <Grid Grid.Column="1"> <TextBlock x:Name="ImageNameFied" Text="{Binding PageText}" TextWrapping="Wrap" Margin="10,10,10,10" FontSize="24" Foreground="AliceBlue" HorizontalAlignment="Center" VerticalAlignment="Center"/> </Grid> </Grid> </Border> </DataTemplate> <!-- Instanciation du template selector pour le flipview --> <local:MZPageTemplateSelector x:Key="pageTemplateSelector" PageTemplate="{StaticResource PageTemplate}"/> </Page.Resources> <!-- Tool bar en bas de la page --> <Page.BottomAppBar> <AppBar IsOpen="True" HorizontalContentAlignment="Center" IsSticky="True"> <Grid> <StackPanel Orientation="Horizontal"> <Button x:Name="PreviousButton" Style="{StaticResource PreviousAppBarButtonStyle}" Click="PreviousButton_Click"/> <Button x:Name="ZoonButton" Style="{StaticResource ZoomAppBarButtonStyle}" Click="ZoonButton_Click"/> <Button x:Name="NextButton" Style="{StaticResource NextAppBarButtonStyle}" Click="NextButton_Click"/> </StackPanel> </Grid> </AppBar> </Page.BottomAppBar> <!-- Grid principal --> <Grid x:Name="MainGrid" Background="{StaticResource ApplicationPageBackgroundThemeBrush}"> <FlipView x:Name="pageFlipView" ItemTemplateSelector="{StaticResource pageTemplateSelector}"></FlipView> </Grid> </Page>
Je patine, je tourne en rond... Est ce qq un aurait juste une petite idée pour orienter mes cherches.
Merci d'avance
Partager