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 :

Controles/header non visible en design d'une Listview


Sujet :

Windows Presentation Foundation

Vue hybride

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

    Informations forums :
    Inscription : Décembre 2006
    Messages : 38
    Par défaut Controles/header non visible en design d'une Listview
    Le bonjour à tous,

    Dans le cadre de mon projet je suis en traind e confectionner un user control qui permet mis dans un expander de faire un gestion des recherches de façon dynamique (en gros on lui passe le nom de la table principal et l'utilisateur fait sa petite requete à sa sauce pour trouver ce qu'il cherche)

    Bref...

    Je devrait avoir qqchose dans ce goût là : http://img371.imageshack.us/img371/2...cherchemu6.jpg

    Malheuseusement (étant débutant en WPF) j'avoue que je me tire les cheveux, car visuellement je ne vois rien dans mon listview (je devrais au moins voir les colonnes dans la partie design non ? parce que la c'est rien mais rien de rien)

    C'est moi ou j'ai loupé qqchose ?

    voici le debut du XAML pour comprendre
    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
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    <UserControl x:Class="WPFUserControls.ucRecherche"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Height="258" Width="641">
        <Grid>
            <TabControl Name="tcRecherche">
                <TabItem Header="Standard">
                    <Grid>
                        <Label Height="28" HorizontalAlignment="Left" Margin="16,16,0,0" Name="lbNegationStd" VerticalAlignment="Top" Width="56">Négation</Label>
                        <Label Height="28" HorizontalAlignment="Left" Margin="74,16,0,0" Name="lbCriteresStd" VerticalAlignment="Top" Width="115">Champ de recherche</Label>
                        <Label Height="28" Margin="241,16,0,0" Name="lbTypeTestStd" VerticalAlignment="Top" HorizontalAlignment="Left" Width="115">Type de test</Label>
                        <Label Height="28" HorizontalAlignment="Left" Margin="400,16,0,0" Name="lbValeurStd" VerticalAlignment="Top" Width="115">Valeur</Label>
                        <ComboBox Height="23" HorizontalAlignment="Left" Margin="16,38,0,0" Name="cbNegationStd" VerticalAlignment="Top" Width="56">
                            <ComboBoxItem>-</ComboBoxItem>
                            <ComboBoxItem>Not</ComboBoxItem>
                        </ComboBox>
                        <TextBox Height="23" HorizontalAlignment="Right" Margin="0,38,88,0" Name="tbValeurStd" VerticalAlignment="Top" Width="135" />
                        <ListView x:Name="lvResultatAdv" Margin="0,81,0,0"  ItemsSource="{Binding}"  IsSynchronizedWithCurrentItem="True" BorderThickness="1,0,1,1">
                                <ListView.View>
                                    <GridView>
                                        <GridViewColumn DisplayMemberBinding="{Binding Path=ID}" Header="Id" Width="120"/>
                                        <GridViewColumn DisplayMemberBinding="{Binding Path=REQUETE}" Header="Requete" Width="250"/>
                                        <GridViewColumn DisplayMemberBinding="{Binding Path=NBLIG}" Header="Nombre de Lignes" Width="120"/>
                                        <GridViewColumn Header="Prise en Compte" Width="50">
                                            <GridViewColumn.CellTemplate>
                                                <DataTemplate>
                                                    <CheckBox IsChecked="{Binding Path=ACTIF}"/>
                                                </DataTemplate>
                                            </GridViewColumn.CellTemplate>
                                        </GridViewColumn>
                                    </GridView>
                                </ListView.View>
                            </ListView>
                    </Grid>
                </TabItem>
                <TabItem Header="Avancée" >
                    <Grid>
                        <Label Height="28" HorizontalAlignment="Left" Margin="16,16,0,0" Name="lbNegationAdv" VerticalAlignment="Top" Width="56">Négation</Label>
                        <Label Height="28" HorizontalAlignment="Left" Margin="74,16,0,0" Name="lbCriteresAdv" VerticalAlignment="Top" Width="115">Champ de recherche</Label>
                        <Label Height="28" Margin="241,16,0,0" Name="lbTypeTestAdv" VerticalAlignment="Top" HorizontalAlignment="Left" Width="115">Type de test</Label>
                        <Label Height="28" HorizontalAlignment="Left" Margin="400,16,0,0" Name="lbValeurAdv" VerticalAlignment="Top" Width="115">Valeur</Label>
                        <ComboBox Height="23" HorizontalAlignment="Left" Margin="16,38,0,0" Name="cbNegationAdv" VerticalAlignment="Top" Width="56">
                            <ComboBoxItem>-</ComboBoxItem>
                            <ComboBoxItem>Not</ComboBoxItem>
                        </ComboBox>
                        <TextBox Height="23" HorizontalAlignment="Right" Margin="0,38,88,0" Name="tbValeurAdv" VerticalAlignment="Top" Width="135" />
                    </Grid>
                </TabItem>
            </TabControl>
        </Grid>
    </UserControl>

  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
    Tu veux dire que là, tu ne vois rien dans ta ListView ? Même pas le Header ?

  3. #3
    Membre averti
    Profil pro
    Inscrit en
    Décembre 2006
    Messages
    38
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2006
    Messages : 38
    Par défaut
    Tout à fait exact.

  4. #4
    Membre Expert
    Profil pro
    Inscrit en
    Décembre 2004
    Messages
    2 210
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2004
    Messages : 2 210
    Par défaut
    Salut,

    je viens de tester et j'ai eu le même comportement (pas de colonne visible dans le designer Visual Studio)... J'ai ensuite essayé de créer une ListView via Blend et de récupérer le style défini par Blend pour le contrôle ListView et en l'utilisant ça fonctionne.

    Donc en ajoutant ce style dans les ressources, les colonnes seront visibles dans le Designer Visual Studio :
    Code xml : 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
        <SolidColorBrush x:Key="ListBorder" Color="#FF7F9DB9"/>
        <Style x:Key="{x:Static GridView.GridViewScrollViewerStyleKey}" TargetType="{x:Type ScrollViewer}">
          <Setter Property="Focusable" Value="false"/>
          <Setter Property="Template">
            <Setter.Value>
              <ControlTemplate TargetType="{x:Type ScrollViewer}">
                <Grid SnapsToDevicePixels="true" Background="{TemplateBinding Background}">
                  <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="Auto"/>
                  </Grid.ColumnDefinitions>
                  <Grid.RowDefinitions>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="Auto"/>
                  </Grid.RowDefinitions>
                  <DockPanel Margin="{TemplateBinding Padding}">
                    <ScrollViewer Focusable="false" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden" DockPanel.Dock="Top">
                      <GridViewHeaderRowPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Columns="{Binding Path=TemplatedParent.View.Columns, RelativeSource={RelativeSource TemplatedParent}}" AllowsColumnReorder="{Binding Path=TemplatedParent.View.AllowsColumnReorder, RelativeSource={RelativeSource TemplatedParent}}" ColumnHeaderContainerStyle="{Binding Path=TemplatedParent.View.ColumnHeaderContainerStyle, RelativeSource={RelativeSource TemplatedParent}}" ColumnHeaderContextMenu="{Binding Path=TemplatedParent.View.ColumnHeaderContextMenu, RelativeSource={RelativeSource TemplatedParent}}" ColumnHeaderTemplate="{Binding Path=TemplatedParent.View.ColumnHeaderTemplate, RelativeSource={RelativeSource TemplatedParent}}" ColumnHeaderTemplateSelector="{Binding Path=TemplatedParent.View.ColumnHeaderTemplateSelector, RelativeSource={RelativeSource TemplatedParent}}" ColumnHeaderToolTip="{Binding Path=TemplatedParent.View.ColumnHeaderToolTip, RelativeSource={RelativeSource TemplatedParent}}"/>
                    </ScrollViewer>
                    <ScrollContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" x:Name="PART_ScrollContentPresenter" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" CanContentScroll="{TemplateBinding CanContentScroll}" KeyboardNavigation.DirectionalNavigation="Local"/>
                  </DockPanel>
                  <ScrollBar Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}" Cursor="Arrow" x:Name="PART_HorizontalScrollBar" Grid.Row="1" Orientation="Horizontal" ViewportSize="{TemplateBinding ViewportWidth}" Maximum="{TemplateBinding ScrollableWidth}" Minimum="0.0" Value="{Binding Path=HorizontalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}"/>
                  <ScrollBar Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" Cursor="Arrow" x:Name="PART_VerticalScrollBar" Grid.Column="1" Orientation="Vertical" ViewportSize="{TemplateBinding ViewportHeight}" Maximum="{TemplateBinding ScrollableHeight}" Minimum="0.0" Value="{Binding Path=VerticalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}"/>
                  <DockPanel Grid.Column="1" Grid.Row="1" Background="{Binding Path=Background, ElementName=PART_VerticalScrollBar}" LastChildFill="false">
                    <Rectangle Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" Fill="White" Width="1" DockPanel.Dock="Left"/>
                    <Rectangle Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}" Fill="White" Height="1" DockPanel.Dock="Top"/>
                  </DockPanel>
                </Grid>
              </ControlTemplate>
            </Setter.Value>
          </Setter>
        </Style>
     
        <Style TargetType="{x:Type ListView}">
          <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"/>
          <Setter Property="BorderBrush" Value="{StaticResource ListBorder}"/>
          <Setter Property="BorderThickness" Value="1"/>
          <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
          <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
          <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
          <Setter Property="ScrollViewer.CanContentScroll" Value="true"/>
          <Setter Property="Template">
            <Setter.Value>
              <ControlTemplate TargetType="{x:Type ListView}">
                <Border SnapsToDevicePixels="true" x:Name="Bd" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
                  <ScrollViewer Style="{DynamicResource {x:Static GridView.GridViewScrollViewerStyleKey}}" Padding="{TemplateBinding Padding}">
                    <ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                  </ScrollViewer>
                </Border>
                <ControlTemplate.Triggers>
                  <Trigger Property="IsGrouping" Value="true">
                    <Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
                  </Trigger>
                  <Trigger Property="IsEnabled" Value="false">
                    <Setter Property="Background" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
                  </Trigger>
                </ControlTemplate.Triggers>
              </ControlTemplate>
            </Setter.Value>
          </Setter>
        </Style>

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

Discussions similaires

  1. Fenêtre d'exportation non visible sur Designer
    Par gautier.c dans le forum Designer
    Réponses: 2
    Dernier message: 09/05/2012, 10h33
  2. Comment rendre un élément d'une ComboList non visible?
    Par The eye dans le forum Windows Forms
    Réponses: 10
    Dernier message: 18/01/2007, 00h32
  3. Réponses: 5
    Dernier message: 12/07/2006, 11h21
  4. Réponses: 1
    Dernier message: 29/12/2005, 18h04
  5. Capture d'une form non visible
    Par Linkin dans le forum Composants VCL
    Réponses: 3
    Dernier message: 14/04/2004, 14h58

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