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

Windows Presentation Foundation Discussion :

Template sur Window


Sujet :

Windows Presentation Foundation

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre confirmé
    Profil pro
    Inscrit en
    Juin 2006
    Messages
    77
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2006
    Messages : 77
    Par défaut Template sur Window
    Bonjour,

    Je découvre les joies des templates et des styles. Néanmoins je suis tombé sur un os, qui semble peut être idiot à première vu mais je n'ai pas trouvé de solution actuellement.

    J'ai créé un template pour une window :

    Code : 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
     <ControlTemplate x:Key="Template_Forms" TargetType="{x:Type Window}">
                <Grid Name="Main_Grid" Background="Transparent">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="24" />
                        <RowDefinition Height="24" />
                        <RowDefinition Height="370*" />
                        <RowDefinition Height="24*" />
                    </Grid.RowDefinitions>
                    <Grid>
                        <Grid.Background>
                            <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
                                <GradientStop Color="Gray" Offset="1.1"></GradientStop>
                                <GradientStop Color="Gray" Offset="0.5"></GradientStop>
                                <GradientStop Color="White" Offset="0.0"></GradientStop>
                            </LinearGradientBrush>
                        </Grid.Background>
                        <StackPanel Name="Upper_SP" Background="Transparent" Orientation="Horizontal" HorizontalAlignment="Right" >
                            <e:ControlBox Name="Reduce_Btn" Function_Type="Reduce" Source="/Caldeira;component/Resources/Reduce.png"></e:ControlBox>
                            <e:ControlBox Name="Level_Btn"  Function_Type="Level"  Source="/Caldeira;component/Resources/stop-icon.png"></e:ControlBox>
                            <e:ControlBox Name="Quit_Btn"  Function_Type="Quit"  Source="/Caldeira;component/Resources/remove-icon.png"></e:ControlBox>
                        </StackPanel>
                    </Grid>
                    <StackPanel Grid.Column="0" Grid.Row="1" Name="ToolBar_SP" Background="Gray" Orientation="Horizontal" Margin="0,0,0,0">
     
                    </StackPanel>
                    <Grid Name="Content_Grid" Grid.Column="0" Grid.Row="2" Background="Gray">
     
                    </Grid>
                    <StackPanel Grid.Column="0" Grid.Row="3"  Name="StackPanel2">
                        <StackPanel.Background>
                            <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
                                <GradientStop Color="Gray" Offset="0.0"></GradientStop>
                                <GradientStop Color="Gray" Offset="0.5"></GradientStop>
                                <GradientStop Color="White" Offset="1.1"></GradientStop>
                            </LinearGradientBrush>
                        </StackPanel.Background>
                    </StackPanel>
                </Grid>
            </ControlTemplate>
    J'appliques ce template à toutes mes fenêtre de mon application. Mais le hic, c'est que tout ce que je rajoute à la fenêtre en plus de ce template n'apparait pas ...

    Exemple sur une de mes fenêtre :

    Code : 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
    <Window x:Class="Profiles_Manager"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Profiles_Manager"  Name="Profile_Manager_Win"  Height="384" Width="453" WindowStyle="None" AllowsTransparency="true" Template="{StaticResource Template_Forms}">
     
     
     
     
        <TreeView Grid.Row="2" Grid.Column="0" Margin="0,0,1,0" Name="TreeView1" Background="Transparent">
            <TreeViewItem IsExpanded="true">
                <TreeViewItem.Header>
                    <StackPanel Orientation="Horizontal" Width="420">
                        <StackPanel.Background>
     
                            <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
                                <GradientStop Color="Gray" Offset="1.1"></GradientStop>
                                <GradientStop Color="LightGray" Offset="0.5"></GradientStop>
                                <GradientStop Color="Gray" Offset="0.0"></GradientStop>
                            </LinearGradientBrush>
                        </StackPanel.Background>
                        <Image Source="/Caldeira;component/Resources/Project.png" Height="20"></Image>
                        <TextBlock Margin="5,0,0,0" Text="YASHAT-1B" VerticalAlignment="Center"></TextBlock>
                    </StackPanel>
                </TreeViewItem.Header>
            </TreeViewItem>
        </TreeView>
     
     
    </Window>

    Le Treeview ajouté sur la Window n'apparait pas ... La solution est peut être bête mais je ne trouve pas la solution ^^

    Merci d'avance pour vos réponses.

  2. #2
    Membre confirmé
    Profil pro
    Inscrit en
    Juin 2006
    Messages
    77
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2006
    Messages : 77
    Par défaut
    J'ai trouvé une partie de ma réponse, mais cela ne me plait pas :

    Code : 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
    Private Sub Main_Loaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles Me.Loaded
            Dim Founded_Btn As IHM.Controls.ControlBox
            Dim Founded_Grid As Grid
    
            Founded_Btn = Me.Template.FindName("Level_Btn", Me)
            Founded_Btn.Owner = Me
            Founded_Btn = Me.Template.FindName("Quit_Btn", Me)
            Founded_Btn.Owner = Me
            Founded_Btn = Me.Template.FindName("Reduce_Btn", Me)
            Founded_Btn.Owner = Me
    
            Founded_Grid = Me.Template.FindName("Content_Grid", Me)
            Profile_Manager_Win.RemoveLogicalChild(TreeView2)
            Founded_Grid.Children.Add(TreeView2)
    
        End Sub
    J'aurais préféré pouvoir faire ca en XAML

  3. #3
    Membre éprouvé Avatar de Thrud
    Profil pro
    Développeur .NET
    Inscrit en
    Avril 2008
    Messages
    170
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : Développeur .NET

    Informations forums :
    Inscription : Avril 2008
    Messages : 170
    Par défaut
    Bonjour,


    essaies avec un ContentPresenter à l'endroit où tu veux insérer ton contenu dans ton Template :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
     
    ...
    <Grid Name="Content_Grid" Grid.Column="0" Grid.Row="2" Background="Gray">
        <ContentPresenter />
    </Grid>
    ...

  4. #4
    Membre confirmé
    Profil pro
    Inscrit en
    Juin 2006
    Messages
    77
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2006
    Messages : 77
    Par défaut
    Citation Envoyé par Thrud Voir le message
    Bonjour,


    essaies avec un ContentPresenter à l'endroit où tu veux insérer ton contenu dans ton Template :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
     
    ...
    <Grid Name="Content_Grid" Grid.Column="0" Grid.Row="2" Background="Gray">
        <ContentPresenter />
    </Grid>
    ...
    Ah merci beaucoup je ne connaissais pas, cela fonctionne !
    Cela m'a permis de découvrir aussi les itemspresenter.

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

Discussions similaires

  1. pb d'installation d'Oracle 9 sur windows 2000
    Par condor dans le forum Oracle
    Réponses: 1
    Dernier message: 14/12/2006, 11h40
  2. pb d'installation d'Oracle 9 sur windows 2000
    Par condor dans le forum Oracle
    Réponses: 1
    Dernier message: 14/06/2006, 14h28
  3. installation postgresql/cygwin/phppgadmin sur windows 98
    Par veneto dans le forum PostgreSQL
    Réponses: 3
    Dernier message: 10/05/2004, 14h28
  4. phpPgAdmin sur windows
    Par krimson dans le forum PostgreSQL
    Réponses: 18
    Dernier message: 14/04/2004, 17h56
  5. [Utilisation Postgresql sur windows]
    Par xhercule dans le forum PostgreSQL
    Réponses: 6
    Dernier message: 26/01/2004, 18h36

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