Bonjour,
Tout d'abord, désolé si ma question est triviale et vous pique les yeux.
Autodidacte, je ne trouve pas de documentation/tutorial qui réponde à mes question, et en mode tâtons, j'ai pas vraiment l'impression d'avancer...
Alors voilà.
J'ai en projet de faire une petite application qui permette de créer des appartements, des locataires, et de suivre les paiement et émettre des quittances de loyer.
L'architecture retenue est :
- Server WCF + SQL Server pour la partie traitements
- Application Windows Universelle pour la partie GUI
J'ai donc créé ma base de données, mes WebServices, tout va bien.
Et je tente de les utiliser depuis mon programme Windows Universel.
Et c'est le drame...
Au démarrage, j'ai une page d'accueil, qui contient :
- Un menu à gauche (bouton "hamburger", vulgaire copier/coller d'un article trouvé sur Google)
- Une zone d'affichage à droite dans un "SplitView.Content"
Voici donc ma page "MainPage.xaml"
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 <Page x:Class="MagicAppartement.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:MagicAppartement" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"> <SplitView x:Name="MySplitView" DisplayMode="CompactOverlay" IsPaneOpen="False" CompactPaneLength="50" OpenPaneLength="200"> <SplitView.Pane> <StackPanel Background="Gray"> <Button x:Name="HamburgerButton" FontFamily="Segoe MDL2 Assets" Content="" Width="50" Height="50" Background="Transparent" Click="HamburgerButton_Click"/> <StackPanel Orientation="Horizontal"> <Button x:Name="btnAppartements" FontFamily="Segoe MDL2 Assets" Content="" Width="50" Height="50" Background="Transparent" Click="btnAppartements_Click"/> <TextBlock Text="Appartements" FontSize="18" VerticalAlignment="Center" /> </StackPanel> <StackPanel Orientation="Horizontal"> <Button x:Name="MenuButton2" FontFamily="Segoe MDL2 Assets" Content="" Width="50" Height="50" Background="Transparent"/> <TextBlock Text="Button 2" FontSize="18" VerticalAlignment="Center" /> </StackPanel> <StackPanel Orientation="Horizontal"> <Button x:Name="MenuButton3" FontFamily="Segoe MDL2 Assets" Content="" Width="50" Height="50" Background="Transparent"/> <TextBlock Text="Button 3" FontSize="18" VerticalAlignment="Center" /> </StackPanel> </StackPanel> </SplitView.Pane> <SplitView.Content> <Grid Background="Black" x:Name="PageContents" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/> </SplitView.Content> </SplitView> </Page>
Et j'ai créé un UserControl dont voici le code XAML :
Code xaml : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8 <UserControl x:Class="MagicAppartement.AppartementTab" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:MagicAppartement" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"> <Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch"> <TextBox x:Name="txtFilter" HorizontalAlignment="Stretch" Margin="10,10,110,10" TextWrapping="Wrap" Text="" VerticalAlignment="Top"/> <Button x:Name="btnSearch" Content="Recherche" HorizontalAlignment="Right" Margin="10,10,10,10" VerticalAlignment="Top" Width="90" Click="btnSearch_Click"/> <ListView x:Name="listeAppartements" HorizontalAlignment="Stretch" Margin="10,50,10,10" VerticalAlignment="Stretch" BorderThickness="2" BorderBrush="Black"/> </Grid> </UserControl>
Dans Visual Studio, mon UserControl ressemble à ça :
Dans la page principale, j'instancie mon UserControl et je le met dans mon SplitView.Content de la façon suivante :
Code csharp : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14 private void btnAppartements_Click(object sender, RoutedEventArgs e) { PageContents.Children.Clear(); if (apptab == null) { apptab = new AppartementTab(); apptab.HorizontalAlignment = HorizontalAlignment.Stretch; apptab.VerticalAlignment = VerticalAlignment.Stretch; } PageContents.Children.Add(apptab); }
Mais voilà... A la place, j'ai ça :
A un moment, j'ai réussi à tout avoir... Mais sans savoir comment il était arrivé ni comment il était reparti, ça c'est remis à déconner...
Partager