ListView列可见性隐藏问题

时间:2011-03-09 07:28:24

标签: windows-phone-7 listview gridview

我想设置col1的可见性,这实际上是GridView的列,而Gridview在ListView中,所以我想通过代码设置隐藏和可见的col1,看它是如何工作的。

    <ListView
        Height="530"
        ItemContainerStyle="{StaticResource MyContainer}"
        x:Name="dgPorfomance">
        <ListView.View >
            <GridView >
                <GridView.Columns>
                    <GridViewColumn x:Name="col1" Width="Auto" Header="Check" CellTemplate="{StaticResource dtChkID}"/>
                    <GridViewColumn x:Name="col2" DisplayMemberBinding="{Binding ID}" Width="50" Header="ID" VirtualizingStackPanel.IsVirtualizing="True"/>
                    <GridViewColumn x:Name="col3" DisplayMemberBinding="{Binding Name}" Width="200" Header="Name" VirtualizingStackPanel.IsVirtualizing="True"/>
                    <GridViewColumn x:Name="col4" DisplayMemberBinding="{Binding Address}" Width="200" Header="Address" VirtualizingStackPanel.IsVirtualizing="True"/>
                    <GridViewColumn x:Name="col5" DisplayMemberBinding="{Binding City}" Width="200" Header="City" VirtualizingStackPanel.IsVirtualizing="True"/>
                    <GridViewColumn x:Name="col6" DisplayMemberBinding="{Binding Pin}" Width="200" Header="Pin" VirtualizingStackPanel.IsVirtualizing="True"/>
                    <GridViewColumn x:Name="col7" DisplayMemberBinding="{Binding Phone}" Width="200" Header="Phone" VirtualizingStackPanel.IsVirtualizing="True"/>
                </GridView.Columns>
            </GridView>
        </ListView.View>
    </ListView>

谢谢.. !!

2 个答案:

答案 0 :(得分:0)

您可以删除该列以使其不可见:

dgPorfomance.Columns.Remove(dgPorfomance.Columns[0])

答案 1 :(得分:0)