2010-02-19 63 views
0

採取我甲肝一類,其存儲文件信息與作爲ITZ的ObservableCollection列表中的項目時,數據被從觀察集合

進口System.Collections.ObjectModel

公共類NameList中 名稱列表繼承的ObservableCollection(中的FileInfo)

' Methods 
Public Sub New() 
    MyBase.Add(New FileInfo("Willa", "Cather", "warning", "err 1")) 
    MyBase.Add(New FileInfo("Isak", "Dinesen", "warning", "err 1")) 
    MyBase.Add(New FileInfo("Victor", "Hugo", "warning", "err 1")) 
    MyBase.Add(New FileInfo("Jules", "Verne", "warning", "err 3")) 
    MyBase.Add(New FileInfo("Victor", "Hugo", "warning", "err 1")) 
    MyBase.Add(New FileInfo("Jules", "Verne", "warning", "err 3")) 
End Sub 

末級

公共類的FileInfo

Public _name As String 
Public _path As String 
Public _image As String 
Public _errorGrp As String 

Public Property ImageIcon() As String 
    Get 
     Return _image 
    End Get 
    Set(ByVal value As String) 
     _image = value 
    End Set 
End Property 

Public Property PathFile() As String 
    Get 
     Return _path 
    End Get 
    Set(ByVal value As String) 
     _path = value 
    End Set 
End Property 

Public Property Name() As String 
    Get 
     Return _name 
    End Get 
    Set(ByVal value As String) 
     _name = value 
    End Set 
End Property 

Public Property ErrorGroup As String 
    Get 
     Return _errorGrp 
    End Get 
    Set(ByVal value As String) 
     _errorGrp = value 
    End Set 
End Property 

Public Sub New(ByVal fileName As String, ByVal filePath As String, ByVal image As String, ByVal errorGrp As String) 
    Name = fileName 
    PathFile = filePath 
    ImageIcon = image 
    ErrorGroup = errorGrp 
End Sub 

末級

我需要此結合其將根據該我試圖errorGroup 我碼進行分組的XAML ListView項是

<Window.Resources > 
    <mydata:NameList x:Key="NameListData"/> 

    <!-- <DataTemplate x:Key="IconListViewItem" > 
     <StackPanel Orientation="Horizontal" > 
      <Image Source="/listViewGroupin;component/Images/ViewType.jpg" Height="19" Width="25" ></Image> 
      <TextBlock Foreground="DarkBlue" Text="{Binding ImageIcon}"/> 
      <TextBlock Foreground="DarkBlue" Text="{Binding Name}"/> 
     </StackPanel> 
    </DataTemplate>--> 

    <CollectionViewSource x:Key='src' 
         Source="{Binding Source={StaticResource NameListData}}"> 
     <CollectionViewSource.GroupDescriptions> 
      <!-- <PropertyGroupDescription PropertyName="ErrorGroup" />--> 
      <PropertyGroupDescription PropertyName="ErrorGroup"/> 
     </CollectionViewSource.GroupDescriptions> 
    </CollectionViewSource> 

</Window.Resources> 
<Grid> 
    <ListView ItemsSource="{Binding Source={StaticResource src}}" 
     IsSynchronizedWithCurrentItem="True" > 
     <ListView.GroupStyle > 
      <GroupStyle > 
       <GroupStyle.ContainerStyle> 
        <Style TargetType="{x:Type GroupItem}"> 
         <Setter Property="Margin" Value="0,0,0,5"/> 
         <Setter Property="Template"> 
          <Setter.Value> 
           <ControlTemplate TargetType="{x:Type GroupItem}"> 

            <GroupBox BorderBrush="Transparent" > 
             <GroupBox.Header > 
              <StackPanel Orientation="Horizontal" > 

               <TextBlock Text="{Binding Name}" 
           Margin="5,0,0,0" Width="100"/> 
               <Border Height=".2" Width="300" Background="Blue" ></Border> 
              </StackPanel> 
             </GroupBox.Header> 
            </GroupBox> 
           </ControlTemplate> 
          </Setter.Value> 
         </Setter> 
        </Style> 
       </GroupStyle.ContainerStyle> 
      </GroupStyle> 
     </ListView.GroupStyle> 

     <ListView.ItemContainerStyle> 
      <Style TargetType="{x:Type ListViewItem}"> 
       <Setter Property="BorderThickness" Value="1" /> 
       <Setter Property="Width" Value="Auto" /> 
       <Setter Property="FontSize" Value="10.4" /> 
      </Style> 
     </ListView.ItemContainerStyle> 

     <ListView.View > 
      <GridView AllowsColumnReorder="False"> 
       <GridViewColumn Width=" 250" Header="File" DisplayMemberBinding="{Binding Name }"> 
       </GridViewColumn> 
       <GridViewColumn Header="Path" Width="350" DisplayMemberBinding="{Binding PathFile}"> 
       </GridViewColumn> 
       <GridViewColumn Header="Error" Width="350" DisplayMemberBinding="{Binding ErrorGroup}"> 
       </GridViewColumn> 
      </GridView> 
     </ListView.View> 
    </ListView> 
</Grid> 

它只給我組名稱和組但不包含項目 請幫我

+0

請人答我...... plzzzzzzzzzz :( – shraddha 2010-02-19 11:14:26

回答

1

您已將ListView.GroupStyle定義爲GroupBox。 GroupBox是一個HeaderedContentControl。 您已經定義的組頭,但你也需要定義一個佔位符項目 -

<GroupBox.Content> 
    <ItemsPresenter /> 
</GroupBox.Content> 
相關問題