Expander as ListView Item RRS feed

  • 问题

  • I need to do a listview that has a muti-column . where the row is an expander.In particular.I have datacollection binding view,I want to show another gridview In expander,expander as Listview Item in have any case,Thank you for you help

    2014年1月7日 8:13


  • 你好,


            <!--xml data-->
            <XmlDataProvider x:Key="MyData" XPath="/Info/Item">
                    <Info xmlns="">
                        <Item ID="12345" Name="Book 1" Price="$32.05"
                    Author="Author A" Catalog="Business"/>
                        <Item ID="13590" Name="Book 2" Price="$10.00"
                    Author="Author B" Catalog="Language"/>
                        <Item ID="24678" Name="Book 3" Price="$9.00"
                    Author="Author C" Catalog="Language"/>
                        <Item ID="65432" Name="Book 4" Price="$8.50"
                    Author="Author D" Catalog="Business"/>
                        <Item ID="11233" Name="Book 5" Price="$19.00"
                    Author="Author E" Catalog="Health"/>
                        <Item ID="94837" Name="Book 6" Price="$8.50"
                    Author="Author F" Catalog="Language"/>
            <CollectionViewSource x:Key='src' Source="{Binding Source={StaticResource MyData}}" />
        <ListView ItemsSource='{Binding Source={StaticResource src}}'
                <Style TargetType="{x:Type ListViewItem}">
                    <Setter Property="Margin" Value="0,0,0,5"/>
                    <Setter Property="Template">
                            <ControlTemplate TargetType="{x:Type ListViewItem}">
                                <Expander IsExpanded="True"
                                            <TextBlock FontWeight="Bold" Text="Expander"
                                                               Margin="5,0,0,0" Width="100"/>
                                        <GridViewRowPresenter Content="{TemplateBinding Content}"
                                                              Columns="{TemplateBinding GridView.ColumnCollection}"/>
                    <GridViewColumn Header="ID"
                            DisplayMemberBinding="{Binding XPath=@ID}"
                            Width="100" />
                    <GridViewColumn Header="Name"
                            DisplayMemberBinding="{Binding XPath=@Name}"
                            Width="140" /> 
                    <GridViewColumn Header="Price"
                            DisplayMemberBinding="{Binding XPath=@Price}"
                            Width="80" />
                    <GridViewColumn Header="Author"
                            DisplayMemberBinding="{Binding XPath=@Author}"
                            Width="80" />



    #How to: Style a Row in a ListView That Implements a GridView

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    2014年1月8日 8:25