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 :

[WPF] Personnalisation tabControl


Sujet :

Windows Presentation Foundation

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre confirmé Avatar de Nanos
    Profil pro
    Inscrit en
    Juin 2009
    Messages
    109
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2009
    Messages : 109
    Par défaut [WPF] Personnalisation tabControl
    Salut à tous,

    J'ai un TabControl utilisant un style que j'avais trouvé sur ce lien (je n'ai utilisé que le style pour le TabControl qui est dans l'archive disponible sur ce lien) : http://www.sythe.org/showthread.php?t=462978 je l'ai donc personnalisé à ma manière (le style) :

    Code WPF : 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
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
                <GradientStopCollection x:Key="Reflection">
                <GradientStop Offset="0.00" Color="#88FFFFFF" />
                <GradientStop Offset="0.20" Color="#66FFFFFF" />
                <GradientStop Offset="0.55" Color="#33FFFFFF" />
                <GradientStop Offset="0.56" Color="#00FFFFFF" />
                <GradientStop Offset="1.00" Color="#22FFFFFF" />
            </GradientStopCollection>
            <LinearGradientBrush StartPoint="0,0" EndPoint="0,1" x:Key="Refl" GradientStops="{StaticResource Reflection}" />
            <LinearGradientBrush StartPoint="0,0" EndPoint="1,0" x:Key="ReflV" GradientStops="{StaticResource Reflection}" />
     
            <Style TargetType="Button" x:Key="ClearBtn">
                <Setter Property="Background" Value="#20000000" />
                <Setter Property="HorizontalContentAlignment" Value="Center" />
                <Setter Property="VerticalContentAlignment" Value="Center" />
                <Setter Property="Padding" Value="3" />
                <Setter Property="BorderThickness" Value="1" />
                <Setter Property="BorderBrush" Value="#30000000" />
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="Button">
                            <Border IsHitTestVisible="True">
     
                                <Grid>
     
                                    <Border Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}"
                        BorderBrush="{TemplateBinding BorderBrush}" CornerRadius="2" Margin="0" SnapsToDevicePixels="True"
                        Name="Hover" Opacity="0">
                                        <Border CornerRadius="1" Background="{StaticResource Refl}">
                                            <Border BorderBrush="#30FFFFFF" BorderThickness="1" CornerRadius="0">
     
                                                <Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="-1">
     
                                                    <Border Opacity="1" Name="HoverHost">
                                                        <Border CornerRadius="1" Background="#40FFFFFF" Opacity="0" HorizontalAlignment="Stretch"
                                  VerticalAlignment="Stretch" />
                                                    </Border>
                                                    <Border CornerRadius="1" Name="Pressed" Background="#40000000" Opacity="0"
                                HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
     
                                                </Grid>
     
                                            </Border>
                                        </Border>
                                    </Border>
                                    <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Name="Presenter"
                        VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Margin="{TemplateBinding Padding}">
     
                                    </ContentPresenter>
                                </Grid>
                            </Border>
     
                            <ControlTemplate.Triggers>
     
                                <Trigger Property="IsPressed" Value="True">
                                    <Trigger.EnterActions>
                                        <BeginStoryboard>
                                            <Storyboard>
                                                <DoubleAnimation Storyboard.TargetName="Pressed" Storyboard.TargetProperty="Opacity"
                              Duration="0:0:0.1" To="0.3" />
                                                <DoubleAnimation Storyboard.TargetName="HoverHost" Storyboard.TargetProperty="Opacity"
                              Duration="0:0:0.1" To="0" />
                                            </Storyboard>
                                        </BeginStoryboard>
                                    </Trigger.EnterActions>
                                    <Trigger.ExitActions>
                                        <BeginStoryboard>
                                            <Storyboard>
                                                <DoubleAnimation Storyboard.TargetName="Pressed" Storyboard.TargetProperty="Opacity"
                              Duration="0:0:0.3" To="0" />
                                                <DoubleAnimation Storyboard.TargetName="HoverHost" Storyboard.TargetProperty="Opacity"
                              Duration="0:0:0.3" To="1" />
                                            </Storyboard>
                                        </BeginStoryboard>
                                    </Trigger.ExitActions>
                                </Trigger>
                                <Trigger Property="IsMouseOver" Value="True">
                                    <Trigger.EnterActions>
                                        <BeginStoryboard>
                                            <Storyboard>
                                                <DoubleAnimation Storyboard.TargetName="Hover" Storyboard.TargetProperty="Opacity"
                              Duration="0:0:0.1" To="1" />
                                            </Storyboard>
                                        </BeginStoryboard>
                                    </Trigger.EnterActions>
                                    <Trigger.ExitActions>
                                        <BeginStoryboard>
                                            <Storyboard>
                                                <DoubleAnimation Storyboard.TargetName="Hover" Storyboard.TargetProperty="Opacity"
                              Duration="0:0:0.3" To="0" />
                                            </Storyboard>
                                        </BeginStoryboard>
                                    </Trigger.ExitActions>
                                </Trigger>
     
                                <Trigger Property="IsEnabled" Value="False">
                                    <Trigger.EnterActions>
                                        <BeginStoryboard>
                                            <Storyboard>
                                                <DoubleAnimation Storyboard.TargetName="Presenter" Storyboard.TargetProperty="Opacity"
                              Duration="0:0:0.3" To="0.5" />
                                            </Storyboard>
                                        </BeginStoryboard>
                                    </Trigger.EnterActions>
                                    <Trigger.ExitActions>
                                        <BeginStoryboard>
                                            <Storyboard>
                                                <DoubleAnimation Storyboard.TargetName="Presenter" Storyboard.TargetProperty="Opacity"
                              Duration="0:0:0.3" To="1.0" />
                                            </Storyboard>
                                        </BeginStoryboard>
                                    </Trigger.ExitActions>
                                </Trigger>
                            </ControlTemplate.Triggers>
     
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
            <Style TargetType="TabControl" x:Key="MainTabControl">
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="TabControl">
                            <Grid SnapsToDevicePixels="True">
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="20" />
                                    <RowDefinition />
                                </Grid.RowDefinitions>
                                <Border Background="#FCFCFC" BorderBrush="#4C4E44" BorderThickness="1" CornerRadius="0,4,4,4" Grid.Row="1"
                      Name="RootBorder">
                                    <ContentPresenter Name="PART_SelectedContentHost" ContentSource="SelectedContent" />
                                </Border>
     
                                <DockPanel HorizontalAlignment="Left">
                                    <Border DockPanel.Dock="Right" Margin="1" BorderBrush="#40FFFFFF" BorderThickness="1"
                        Background="#20000000" VerticalAlignment="Center" CornerRadius="3">
     
                                        <Button Width="15" Height="15" Command="New" Style="{StaticResource ClearBtn}" Padding="2">
                                            <Path Stroke="#F0FFFFFF" StrokeThickness="2" Data="M 5,0 5,10 M 0,5 10,5" Stretch="Uniform" />
                                        </Button>
                                    </Border>
                                    <UniformGrid Rows="1" IsItemsHost="True" />
                                </DockPanel>
                            </Grid>
                            <ControlTemplate.Triggers>
                                <Trigger Property="SelectedItem" Value="{x:Null}">
                                    <Setter TargetName="RootBorder" Property="CornerRadius" Value="4" />
                                </Trigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
                <Setter Property="ItemContainerStyle">
                    <Setter.Value>
                        <Style TargetType="TabItem">
                            <Setter Property="Template">
                                <Setter.Value>
                                    <ControlTemplate TargetType="TabItem">
                                        <Border Opacity="0.7" Name="RootGrid">
                                            <Border BorderBrush="#4C4E44" BorderThickness="1,1,1,0" HorizontalAlignment="Stretch"
                            Name="RootElement" CornerRadius="3,3,0,0" SnapsToDevicePixels="True" Opacity="0.7"
                            Margin="-1,2,0,0">
                                                <Border.Background>
                                                    <LinearGradientBrush EndPoint="0,1">
                                                        <GradientStop Offset="0" Color="Black" />
                                                        <GradientStop Offset="0.9" Color="White" />
                                                    </LinearGradientBrush>
                                                </Border.Background>
                                                <Grid Margin="4,0" HorizontalAlignment="Stretch" VerticalAlignment="Center">
                                                    <ContentPresenter ContentSource="Header" Margin="0,0,17,0" Width="100" />
                                                    <Button DockPanel.Dock="Right" Width="15" Height="15" Command="Close" Margin="1,0"
                                Style="{StaticResource ClearBtn}" Visibility="Visible" Name="CloseBtn"
                                HorizontalAlignment="Right" VerticalAlignment="Center">
                                                        <Path Stroke="#80000000" StrokeThickness="2" Data="M 0,0 10,10 M 10,0 0,10" Stretch="Uniform" />
                                                    </Button>
                                                </Grid>
                                            </Border>
                                        </Border>
                                        <ControlTemplate.Triggers>
                                            <Trigger Property="IsSelected" Value="True">
                                                <Setter TargetName="RootElement" Property="Margin" Value="-1,0,0,-1" />
                                                <Setter TargetName="RootElement" Property="Opacity" Value="1" />
                                                <Setter TargetName="RootGrid" Property="Opacity" Value="1" />
                                                <Setter Property="Panel.ZIndex" Value="1" />
                                            </Trigger>
                                            <Trigger Property="IsMouseOver" Value="True">
                                                <Setter TargetName="RootGrid" Property="Opacity" Value="1" />
                                            </Trigger>
                                        </ControlTemplate.Triggers>
                                    </ControlTemplate>
                                </Setter.Value>
                            </Setter>
                        </Style>
                    </Setter.Value>
                </Setter>
            </Style>

    Mais ce que je veut faire c'est faire en sorte que pour toutes mes tabItems, j'ai mon favicon qui s'affiche : le problème ce n'est pas comment le récupérer -> ça je sais le faire mais ce que je veut c'est comme j'ai dit qu'il y est un emplacement sur mes tabItems à gauche pour mettre mes favicons mais aussi c'est que je puisse accéder au favicon (le changer) par l'intermédiaire du code.

    Exemple :

    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
            private void WebKitBrowser_DocumentCompleted(object sender, System.Windows.Forms.WebBrowserDocumentCompletedEventArgs e)
            {
                try
                {
                    WebKit.WebKitBrowser wb = sender as WebKit.WebKitBrowser;
                    System.Windows.Forms.Control adapter = wb.Parent;
                    System.Reflection.Assembly asm = typeof(System.Windows.Forms.Integration.WindowsFormsHost).Assembly;
                    System.Type type = asm.GetType("System.Windows.Forms.Integration.WinFormsAdapter");
                    object parent = type.InvokeMember("_host",System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.GetField | System.Reflection.BindingFlags.Instance,null,adapter,new System.Object[] { });
                    System.Windows.Forms.Integration.WindowsFormsHost windowsFormsHost = parent as System.Windows.Forms.Integration.WindowsFormsHost;
                    System.Windows.Controls.TabItem tabPage = windowsFormsHost.Parent as System.Windows.Controls.TabItem;
    
                    tabPage.Header = wb.DocumentTitle;
    
                    tabPage.FaviconUri = "http://" + wb.Url.Authority + "/favicon.ico";
                }
                catch (System.Exception ex)
                {
                    System.Windows.MessageBox.Show(ex.Message, "Erreur", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error);
                }
            }

    Je souhaite y accéder comme la partie écrite en rouge.

    Par contre j'ai remarqué que les image *.gif ne marchait pas car moi j'aurais besoin de mettre un gif de chargement dans mon emplacement pour les favicons.

    Aussi (eh oui je demande beaucoup ) est-ce qu'il est possible de faire un glissez-déposer d'onglet comme sur google chrome ?

    Est-ce possible ? Si oui ou non, comment faire ?

    Pouvez-vous m'aidez S.V.P ?

    Merci d'avance.

  2. #2
    Rédacteur
    Avatar de Thomas Lebrun
    Profil pro
    Inscrit en
    Octobre 2002
    Messages
    9 161
    Détails du profil
    Informations personnelles :
    Âge : 43
    Localisation : France

    Informations forums :
    Inscription : Octobre 2002
    Messages : 9 161
    Par défaut
    Si tu veux pouvoir ajouter une Favicon à tes onglets, tu vas devoir créer un Custom Control qui hérite de TabControl pour rajouter ta propriété.

  3. #3
    Membre confirmé Avatar de Nanos
    Profil pro
    Inscrit en
    Juin 2009
    Messages
    109
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2009
    Messages : 109
    Par défaut
    Salut,

    Sa y'es, j'ai créer mon TabControl dans un fichier CustomConstrol, j'ai ajouté ton code pour le Drag & Drop, ce qui me donne :

    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
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    namespace Protom_Navigator
    {
        /// <summary>
        /// Suivez les étapes 1a ou 1b puis 2 pour utiliser ce contrôle personnalisé dans un fichier XAML.
        ///
        /// Étape 1a) Utilisation de ce contrôle personnalisé dans un fichier XAML qui existe dans le projet actif.
        /// Ajoutez cet attribut XmlNamespace à l'élément racine du fichier de balisage où il doit 
        /// être utilisé*:
        ///
        ///     xmlns:MyNamespace="clr-namespace:Protom_Navigator"
        ///
        ///
        /// Étape 1b) Utilisation de ce contrôle personnalisé dans un fichier XAML qui existe dans un autre projet.
        /// Ajoutez cet attribut XmlNamespace à l'élément racine du fichier de balisage où il doit 
        /// être utilisé*:
        ///
        ///     xmlns:MyNamespace="clr-namespace:Protom_Navigator;assembly=Protom_Navigator"
        ///
        /// Vous devrez également ajouter une référence du projet contenant le fichier XAML
        /// à ce projet et régénérer pour éviter des erreurs de compilation*:
        ///
        ///     Cliquez avec le bouton droit sur le projet cible dans l'Explorateur de solutions, puis sur
        ///     "Ajouter une référence"->"Projets"->[Recherchez et sélectionnez ce projet]
        ///
        ///
        /// Étape 2)
        /// Utilisez à présent votre contrôle dans le fichier XAML.
        ///
        ///     <MyNamespace:TabControlSource/>
        ///
        /// </summary>
        /// 
        public class TabControlProtomNavigator : System.Windows.Controls.TabControl
        {
            public TabControlProtomNavigator()
            {
                AllowDrop = true;
                MouseMove += TabControlProtomNavigator_MouseMove;
                DragOver += TabControlProtomNavigator_DragOver;
                Drop += TabControlProtomNavigator_Drop;
            }
     
            void TabControlProtomNavigator_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
            {
                if (e.LeftButton == System.Windows.Input.MouseButtonState.Pressed)
                {
                    System.Windows.DragDropEffects effects;
                    System.Windows.DataObject obj = new System.Windows.DataObject();
                    obj.SetData(typeof(string), TabControlProtomNavigator);
                    effects = System.Windows.DragDrop.DoDragDrop(System.Windows.Controls.TabItem, obj, System.Windows.DragDropEffects.Copy | System.Windows.DragDropEffects.Move);
                }
            }
     
            void TabControlProtomNavigator_DragOver(object sender, System.Windows.DragEventArgs e)
            {
                if (e.Data.GetDataPresent(typeof(string)))
                {
                    e.Effects = System.Windows.DragDropEffects.Copy;
                }
                else
                {
                    e.Effects = System.Windows.DragDropEffects.None;
                }
            }
     
            void TabControlProtomNavigator_Drop(object sender, System.Windows.DragEventArgs e)
            {
                if (e.Data.GetDataPresent(typeof(string)))
                {
                    e.Effects = System.Windows.DragDropEffects.Copy;
                    string uri = (string)e.Data.GetData(typeof(string));
                    // Utiliser uri comme vous le souhaitez
                }
                else
                {
                    e.Effects = System.Windows.DragDropEffects.None;
                }
            }
        }
    }

    Maintenant que j'ai fait sa, il me reste de définir les style et sa, sa va être la première fois. Je ne sais pas comment sa se passe, comment marche les ... get set ? Bien sur, je ne te demande pas de me donner un code complet qui résoudra mes problèmes mais de m'aider en me disant comment définir un style etc...

  4. #4
    Rédacteur
    Avatar de Thomas Lebrun
    Profil pro
    Inscrit en
    Octobre 2002
    Messages
    9 161
    Détails du profil
    Informations personnelles :
    Âge : 43
    Localisation : France

    Informations forums :
    Inscription : Octobre 2002
    Messages : 9 161
    Par défaut
    Pour créer le style, tu peux utiliser Expression Blend pour créer une copie du style par défaut. Ensuite, tu n'as plus qu'à modifier ce style par défaut pour l'adapter à tes besoins.

  5. #5
    Membre confirmé Avatar de Nanos
    Profil pro
    Inscrit en
    Juin 2009
    Messages
    109
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2009
    Messages : 109
    Par défaut
    Citation Envoyé par Thomas Lebrun Voir le message
    Pour créer le style, tu peux utiliser Expression Blend pour créer une copie du style par défaut. Ensuite, tu n'as plus qu'à modifier ce style par défaut pour l'adapter à tes besoins.
    Comment peut s'utiliser Expression Blend (jamais entendu parler). Sinon j'ai commencer a faire mon style en C# (je n'ai fait que les premières lignes et sa me paraît un peu long) :

    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
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    namespace Protom_Navigator
    {
        /// <summary>
        /// Suivez les étapes 1a ou 1b puis 2 pour utiliser ce contrôle personnalisé dans un fichier XAML.
        ///
        /// Étape 1a) Utilisation de ce contrôle personnalisé dans un fichier XAML qui existe dans le projet actif.
        /// Ajoutez cet attribut XmlNamespace à l'élément racine du fichier de balisage où il doit 
        /// être utilisé*:
        ///
        ///     xmlns:MyNamespace="clr-namespace:Protom_Navigator"
        ///
        ///
        /// Étape 1b) Utilisation de ce contrôle personnalisé dans un fichier XAML qui existe dans un autre projet.
        /// Ajoutez cet attribut XmlNamespace à l'élément racine du fichier de balisage où il doit 
        /// être utilisé*:
        ///
        ///     xmlns:MyNamespace="clr-namespace:Protom_Navigator;assembly=Protom_Navigator"
        ///
        /// Vous devrez également ajouter une référence du projet contenant le fichier XAML
        /// à ce projet et régénérer pour éviter des erreurs de compilation*:
        ///
        ///     Cliquez avec le bouton droit sur le projet cible dans l'Explorateur de solutions, puis sur
        ///     "Ajouter une référence"->"Projets"->[Recherchez et sélectionnez ce projet]
        ///
        ///
        /// Étape 2)
        /// Utilisez à présent votre contrôle dans le fichier XAML.
        ///
        ///     <MyNamespace:TabControlSource/>
        ///
        /// </summary>
        /// 
        public class TabControlProtomNavigator : System.Windows.Controls.TabControl
        {
            public TabControlProtomNavigator()
            {
                AllowDrop = true;
                MouseMove += TabControlProtomNavigator_MouseMove;
                DragOver += TabControlProtomNavigator_DragOver;
                Drop += TabControlProtomNavigator_Drop;
     
                System.Windows.Media.GradientStopCollection Reflection = new System.Windows.Media.GradientStopCollection();
                System.Windows.Media.GradientStop GS1 = new System.Windows.Media.GradientStop();
                GS1.Offset = 0.00;
                GS1.Color = new System.Windows.Media.Color(System.Windows.Media.Color.FromArgb(88,00,00,00));
                System.Windows.Media.GradientStop GS2 = new System.Windows.Media.GradientStop();
                GS2.Offset = 0.20;
                GS2.Color = new System.Windows.Media.Color(System.Windows.Media.Color.FromArgb(66, 00, 00, 00));
                System.Windows.Media.GradientStop GS3 = new System.Windows.Media.GradientStop();
                GS3.Offset = 0.55;
                GS3.Color = new System.Windows.Media.Color(System.Windows.Media.Color.FromArgb(33, 00, 00, 00));
                System.Windows.Media.GradientStop GS4 = new System.Windows.Media.GradientStop();
                GS4.Offset = 0.56;
                GS4.Color = new System.Windows.Media.Color(System.Windows.Media.Color.FromArgb(00, 00, 00, 00));
                System.Windows.Media.GradientStop GS5 = new System.Windows.Media.GradientStop();
                GS5.Offset = 1.00;
                GS5.Color = new System.Windows.Media.Color(System.Windows.Media.Color.FromArgb(22, 00, 00, 00));
                Reflection.Add(GS1);
                Reflection.Add(GS2);
                Reflection.Add(GS3);
                Reflection.Add(GS4);
                Reflection.Add(GS5);
                System.Windows.Media.LinearGradientBrush Refl = new System.Windows.Media.LinearGradientBrush();
                Refl.StartPoint = new System.Windows.Point(0, 0);
                Refl.EndPoint = new System.Windows.Point(0, 1);
                Refl.GradientStops = new System.Windows.Media.GradientStopCollection(Reflection);
                System.Windows.Media.LinearGradientBrush ReflV = new System.Windows.Media.LinearGradientBrush();
                ReflV.StartPoint = new System.Windows.Point(0, 0);
                ReflV.EndPoint = new System.Windows.Point(1, 0);
                ReflV.GradientStops = new System.Windows.Media.GradientStopCollection(Reflection);
                System.Windows.Style ClearBtn = new System.Windows.Style();
                ClearBtn.TargetType = System.Windows.Controls.Button;
                System.Windows.Setter S = new System.Windows.Setter();
                S.Property = new System.Windows.DependencyProperty(Background = System.Windows.Media.Color(System.Windows.Media.Color.FromArgb(20,00,00,00));
            }
     
            void TabControlProtomNavigator_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
            {
                if (e.LeftButton == System.Windows.Input.MouseButtonState.Pressed)
                {
                    System.Windows.DragDropEffects effects;
                    System.Windows.DataObject obj = new System.Windows.DataObject();
                    obj.SetData(typeof(string), TabControlProtomNavigator);
                    effects = System.Windows.DragDrop.DoDragDrop(System.Windows.Controls.TabItem, obj, System.Windows.DragDropEffects.Copy | System.Windows.DragDropEffects.Move);
                }
            }
     
            void TabControlProtomNavigator_DragOver(object sender, System.Windows.DragEventArgs e)
            {
                if (e.Data.GetDataPresent(typeof(string)))
                {
                    e.Effects = System.Windows.DragDropEffects.Copy;
                }
                else
                {
                    e.Effects = System.Windows.DragDropEffects.None;
                }
            }
     
            void TabControlProtomNavigator_Drop(object sender, System.Windows.DragEventArgs e)
            {
                if (e.Data.GetDataPresent(typeof(string)))
                {
                    e.Effects = System.Windows.DragDropEffects.Copy;
                    string uri = (string)e.Data.GetData(typeof(string));
                    // Utiliser uri comme vous le souhaitez
                }
                else
                {
                    e.Effects = System.Windows.DragDropEffects.None;
                }
            }
        }
    }

    Equivalent WPF :

    Code WPF : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
            <GradientStopCollection x:Key="Reflection">
                <GradientStop Offset="0.00" Color="#88FFFFFF" />
                <GradientStop Offset="0.20" Color="#66FFFFFF" />
                <GradientStop Offset="0.55" Color="#33FFFFFF" />
                <GradientStop Offset="0.56" Color="#00FFFFFF" />
                <GradientStop Offset="1.00" Color="#22FFFFFF" />
            </GradientStopCollection>
            <LinearGradientBrush StartPoint="0,0" EndPoint="0,1" x:Key="Refl" GradientStops="{StaticResource Reflection}" />
            <LinearGradientBrush StartPoint="0,0" EndPoint="1,0" x:Key="ReflV" GradientStops="{StaticResource Reflection}" />
     
            <Style TargetType="Button" x:Key="ClearBtn">
                <Setter Property="Background" Value="#20000000" />

    Tandis qu'il faut que je fasse CINQUANTE fois ça ^^ . Ça va être long à part si il existe un convertisseur XAML vers C# sur internet. Je suis sur la bonne voie ? Comment utiliser Expression Blend ?

  6. #6
    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 Hades Shion Voir le message
    Comment peut s'utiliser Expression Blend (jamais entendu parler).
    Voir ici :
    http://www.microsoft.com/france/expr...on_Studio.aspx

    Expression Blend est un outil qui permet de modifier toute la partie Design des projets WPF.
    Il n'est pas gratuit !

    Personnellement je fais sans !

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

Discussions similaires

  1. [WPF] Personnaliser DataGrid
    Par Babas007 dans le forum Windows Presentation Foundation
    Réponses: 6
    Dernier message: 30/11/2010, 16h11
  2. [WPF] Binding TabControl Personalisé
    Par NeoKript dans le forum Windows Presentation Foundation
    Réponses: 2
    Dernier message: 16/06/2010, 21h24
  3. [WPF] Style TabControl
    Par NeoKript dans le forum Windows Presentation Foundation
    Réponses: 4
    Dernier message: 05/06/2010, 16h48
  4. [WPF] Datatemplate & Tabcontrol
    Par NeoKript dans le forum Windows Presentation Foundation
    Réponses: 8
    Dernier message: 01/04/2010, 19h13
  5. Réponses: 2
    Dernier message: 21/09/2007, 17h28

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