IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Silverlight Discussion :

problème utilisation navigation:frame


Sujet :

Silverlight

  1. #1
    Membre confirmé
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Octobre 2011
    Messages
    216
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Octobre 2011
    Messages : 216
    Par défaut problème utilisation navigation:frame
    bonjour,

    j' ai un problème au niveau de ma Frame, je ne peut pas charger de page, voici mon code :

    Code xaml : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
                <navigation:Frame x:Name="ContentFrame" 
                                  Source="/Vue/graphep.xaml" NavigationFailed="contenu_NavigationFailed">
                    <navigation:Frame.UriMapper>
                        <uriMapper:UriMapper>
                            <uriMapper:UriMapping Uri="" MappedUri="/Vue/graphep.xaml"/>
                            <uriMapper:UriMapping Uri="/{pageName}" MappedUri="/Vue/{pageName}.xaml"/>
                        </uriMapper:UriMapper>
                    </navigation:Frame.UriMapper>
                </navigation:Frame>

    en fichier joint l' arboresence de mon projet.

    j' ai également testé ca :

    Code xaml : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
                <navigation:Frame x:Name="ContentFrame" 
                                  Source="/graphep" NavigationFailed="contenu_NavigationFailed">
                    <navigation:Frame.UriMapper>
                        <uriMapper:UriMapper>
                            <uriMapper:UriMapping Uri="" MappedUri="/graphep"/>
                            <uriMapper:UriMapping Uri="/{pageName}" MappedUri="/Vue/{pageName}.xaml"/>
                        </uriMapper:UriMapper>
                    </navigation:Frame.UriMapper>
                </navigation:Frame>

    voici le code xaml complet:

    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
    <UserControl xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"  
                 xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"  
                 x:Class="test_appli.MainPage"
                 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                 xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation" 
                 xmlns:uriMapper="clr-namespace:System.Windows.Navigation;assembly=System.Windows.Controls.Navigation"
                 xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                 mc:Ignorable="d" d:DesignHeight="900" d:DesignWidth="1200">
     
     
        <Grid x:Name="LayoutRoot" Background="White">
            <Border Height="135" HorizontalAlignment="Left" Margin="0,0,0,765" Name="border_haut" VerticalAlignment="Bottom" Width="1200" Background="#FFCE3A3A">
                <Grid>
                    <ComboBox Height="30" Name="cbxContrat" Margin="49,52,902,53" />
                    <ComboBox Margin="512,51,0,0" Name="cbxAnnee" Height="31" VerticalAlignment="Top" HorizontalAlignment="Left" Width="168" IsEnabled="False" />
                    <Button Content="Valider" Height="71" HorizontalAlignment="Left" Margin="970,31,0,0" Name="btnvalider" VerticalAlignment="Top" Width="135" />
                </Grid>
            </Border>
     
            <Border Height="715" HorizontalAlignment="Left" Margin="0,135,0,50" Name="border_host" Width="1200" Background="#FF549AB1" VerticalAlignment="Bottom" >
     
                <navigation:Frame x:Name="ContentFrame" 
                                  Source="/graphep" NavigationFailed="contenu_NavigationFailed">
                    <navigation:Frame.UriMapper>
                        <uriMapper:UriMapper>
                            <uriMapper:UriMapping Uri="" MappedUri="/graphep"/>
                            <uriMapper:UriMapping Uri="/{pageName}" MappedUri="/Vue/{pageName}.xaml"/>
                        </uriMapper:UriMapper>
                    </navigation:Frame.UriMapper>
                </navigation:Frame>
     
            </Border>
     
            <Border Height="50" HorizontalAlignment="Left" Margin="0,0,0,0" Name="border_bas" VerticalAlignment="Bottom" Width="1200" Background="#FF509D50">
                <sdk:Label Height="50" HorizontalAlignment="Left" Margin="319,0,0,0" Name="lblposition" VerticalAlignment="Top" Width="673" />
            </Border>
        </Grid>
     
    </UserControl>

    pouvez vous m' aider please ?

    Merci
    Images attachées Images attachées  

  2. #2
    Membre éprouvé
    Homme Profil pro
    Inscrit en
    Juillet 2011
    Messages
    82
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Juillet 2011
    Messages : 82
    Par défaut
    Bonsoir,

    en premier lieu personnellement je donnerai un nom symbolique a ton url par defaut

    Code xaml : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
     
    <uriMapper:UriMapper>
                            <uriMapper:UriMapping Uri="Graphique" MappedUri="/Vue/graphep.xaml"/>
                            <uriMapper:UriMapping Uri="/{pageName}" MappedUri="/Vue/{pageName}.xaml"/>
    </uriMapper:UriMapper>

    Ce qui du coup peut aussi renvoyer a modifier ton nom de vue (.xaml) pour correspondre a des noms plus conviviaux (pourquoi ne pas renommer ton fichier graphep.xaml en graphique.xaml ?), ainsi tu mappe beaucoup moins.

    Code xaml : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
     
    <navigation:Frame x:Name="ContentFrame" 
                                  Source="Graphique" NavigationFailed="contenu_NavigationFailed">
                    <navigation:Frame.UriMapper>
                        <uriMapper:UriMapper>
                            <uriMapper:UriMapping Uri="/{pageName}" MappedUri="/Vue/{pageName}.xaml"/>
                        </uriMapper:UriMapper>
                    </navigation:Frame.UriMapper>
    </navigation:Frame>

    Ton fichier graphep.xaml doit etre de type navigation:page , pas UserControl ou FenetreEnfant mais bien de type Page, sinon ca marche pas.

    Code xaml : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
     
    <navigation:Page
    xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation">
     
    </navigation:Page>

    Pour ton exemple tu pouvais laisser la source de ton NavigationFrame vide pour que le mapping fonctionnes (sinon il cherche un truc genre /Vue//Vue/graphep.xaml.xaml correspondant a ton string.Format)

  3. #3
    Rédacteur
    Avatar de lutecefalco
    Profil pro
    zadzdzddzdzd
    Inscrit en
    Juillet 2005
    Messages
    5 052
    Détails du profil
    Informations personnelles :
    Âge : 45
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : zadzdzddzdzd

    Informations forums :
    Inscription : Juillet 2005
    Messages : 5 052
    Par défaut
    Citation Envoyé par Vinchenzo.939 Voir le message

    Ton fichier graphep.xaml doit etre de type navigation:page , pas UserControl ou FenetreEnfant mais bien de type Page, sinon ca marche pas.
    Chez moi ça fonctionne sans passer par des pages

  4. #4
    Membre confirmé
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Octobre 2011
    Messages
    216
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Octobre 2011
    Messages : 216
    Par défaut
    bonjour,

    voila ou j' en suis, j' ai rajouter une page "acceuil" et voici le code actuel:

    Code xaml : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
                <navigation:Frame x:Name="ContentFrame" Source="/acceuil"  NavigationFailed="contenu_NavigationFailed">
                    <navigation:Frame.UriMapper>
                        <uriMapper:UriMapper>
                            <uriMapper:UriMapping Uri="Graphique" MappedUri="/Vue/graphep.xaml"/>
                            <uriMapper:UriMapping Uri="/{pageName}" MappedUri="/Vue/{pageName}.xaml"/>
                        </uriMapper:UriMapper>
                    </navigation:Frame.UriMapper>
                </navigation:Frame>

    quand l' appli se lance j' ai bien la page acceuil qui apparait, comment je fais pour qu' il affiche la page graphep.xaml ?

    j' ai un bouton mais je ne sais pas comment lui dire dans le code-behind que je souhaite changer l' affichage de ma frame,

    dois-je changer la source?

    le bouton n' est pas un hyperlinkbouton, est ce grave ?

    Merci.

  5. #5
    Membre confirmé
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Octobre 2011
    Messages
    216
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Octobre 2011
    Messages : 216
    Par défaut
    bonjour,

    j' ai trouver sur un autre post:

    http://www.developpez.net/forums/d87...perlinkbutton/

    la syntaxe pour changer la vue en code-behind:

    Code c# : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
            {
                this.FrameContenu.Source=(new Uri("Views/Logs.xaml",UriKind.Relative));
            }

    alors j' ai voulu l' adapter a mon code en faisant:

    Code c# : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
            {
                ContentFrame.Navigate(Graphique);
            }

    puisque mon code xaml est:

    Code xaml : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
                            <uriMapper:UriMapping Uri="Graphique" MappedUri="/Vue/graphep.xaml"/>
                            <uriMapper:UriMapping Uri="/{pageName}" MappedUri="/Vue/{pageName}.xaml"/>

    mais ça ne marche pas, donc j' ai tenté:

    Code c# : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
            {
                ContentFrame.Navigate(new Uri("Vue/graphep.xaml", UriKind.Relative));
            }

    ça marche pas non plus.

    je me demande aussi a quoi ca sert de faire le UriMapper en xaml si on dois faire un new uri en c#.

    Merci

  6. #6
    Membre éprouvé
    Homme Profil pro
    Inscrit en
    Juillet 2011
    Messages
    82
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Juillet 2011
    Messages : 82
    Par défaut
    Bonsoir,

    Alors plusieurs choses.
    Depuis ton mainPage utilises, en effet, ton contentFrame (depuis une Page, utilise ton NavigationService)

    Tu avait la bonne syntaxe,
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    ContentFrame.Navigate(new Uri("/Graphique", UriKind.Relative));
    Attention a la barre oblique quand tu fait du UriMapped

    Pour le deuxieme point, l'interet de faire du mapping, c'est pour ta barre de navigateur (cote navigateur internet) l'url apparait avec un format plus sympa, ce qui est pratique pour faire "tourner" des liens

  7. #7
    Membre confirmé
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Octobre 2011
    Messages
    216
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Octobre 2011
    Messages : 216
    Par défaut
    bonjour,

    Merci c' est bon, ça marche.

    MERCI A TOUS

    ++

  8. #8
    Membre confirmé
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Octobre 2011
    Messages
    216
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Octobre 2011
    Messages : 216
    Par défaut
    en fait, ça marche pas bien, quand je fais :

    Code c# : Sélectionner tout - Visualiser dans une fenêtre à part
                ContentFrame.Navigate(new Uri("/Graphique", UriKind.Relative));

    ça m' instancie une nouvelle page,

    j' ai dans ma MainPage une page :


    et c' est cette "graphep" que je souhaite afficher dans ma frame car je fais des modif a ma page :
    "graphiquep"

    et ca ne se voit pas dans la page qui est affiché dans ma frame.

    comment obtenir l' uri de ma page : "graphiquep" ?

    pour indiquer a ma ferame de m' afficher cette page ?

    Merci.

  9. #9
    Membre éprouvé
    Homme Profil pro
    Inscrit en
    Juillet 2011
    Messages
    82
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Juillet 2011
    Messages : 82
    Par défaut
    Ah, understood.

    En fait c'est pas vraiment de la navigation que tu souhaite, c'est afficher une page existante (on vas dire cache dans les meandres de ton code-behind).

    Donc en effet il ne faut pas Navigate, mais rester Content

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    ContentFrame.Content = maPage;

  10. #10
    Membre confirmé
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Octobre 2011
    Messages
    216
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Octobre 2011
    Messages : 216
    Par défaut
    oki, ça fonctionne exactement comme je voulais.

    Merci Merci.

    + +

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [Tomcat][Spring] Problème utilisation mémoire
    Par Wutintin dans le forum Hibernate
    Réponses: 12
    Dernier message: 08/09/2005, 14h57
  2. [JSTL] [EL] Problème utilisation <c:out>
    Par XavierL dans le forum Taglibs
    Réponses: 7
    Dernier message: 14/08/2005, 20h12
  3. (Problème) Utilisation de l'API mySQL [Delphi 2005 Perso]
    Par will-scs dans le forum Bases de données
    Réponses: 2
    Dernier message: 08/08/2005, 18h26
  4. [JAR]Problème utilisation manifest et jar
    Par doudine dans le forum Eclipse Java
    Réponses: 6
    Dernier message: 07/01/2005, 10h21
  5. Utiliser les frames
    Par laury dans le forum Composants VCL
    Réponses: 5
    Dernier message: 10/05/2003, 10h14

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo