我在WPF中有一个listview,我希望在其中冻结多个列(last four columns
)。
以下是我的代码:
<ListView Name="lvShowSearching" ItemsSource="{Binding Path=.}" Height="248" RenderTransformOrigin="2.25,4" Margin="1129,159,26,93" Grid.RowSpan="2" VerticalAlignment="Center" BorderThickness="2" BorderBrush="#FF90A1CD" Background="White" >
<ListView.View>
<GridView>
<GridViewColumn Width="0" DisplayMemberBinding="{Binding KeywordID}">
<ItemsPanelTemplate>
<StackPanel Visibility="Hidden"></StackPanel>
</ItemsPanelTemplate>
</GridViewColumn>
<GridViewColumn Header="First Name" Width="100" DisplayMemberBinding="{Binding FirstName}">
</GridViewColumn>
<GridViewColumn Header="Last Name" Width="100" DisplayMemberBinding="{Binding LastName}" />
<GridViewColumn Header="All Words" Width="100" DisplayMemberBinding="{Binding WithAllOfTheWords}" />
<GridViewColumn Header="Exact Phrase" Width="100" DisplayMemberBinding="{Binding WithTheExactPhrase}" />
<GridViewColumn Header="At Least One Word" Width="120" DisplayMemberBinding="{Binding WithAtLeastOneOfTheseWords}" />
<GridViewColumn Header="Without Word" Width="100" DisplayMemberBinding="{Binding WithoutTheWord}" />
<GridViewColumn Header="Exact Date" Width="100" DisplayMemberBinding="{Binding Path=ExactDate, StringFormat='MM/dd/yyyy'}" />
<GridViewColumn Header="Start Date" Width="100" DisplayMemberBinding="{Binding Path=StartDate, StringFormat='MM/dd/yyyy'}" />
<GridViewColumn Header="End Date" Width="100" DisplayMemberBinding="{Binding Path=EndDate, StringFormat='MM/dd/yyyy'}" />
<GridViewColumn Header="Start Year" Width="100" DisplayMemberBinding="{Binding StartYears}" />
<GridViewColumn Header="End Year" Width="100" DisplayMemberBinding="{Binding EndYear}" />
<GridViewColumn Header="Country" Width="100" DisplayMemberBinding="{Binding CountryName}"/>
<GridViewColumn Header="State" Width="100" DisplayMemberBinding="{Binding StateName}" />
<GridViewColumn Header="City" Width="100" DisplayMemberBinding="{Binding CityName}" />
<GridViewColumn Header="Publication" Width="100" DisplayMemberBinding="{Binding PublicationName}" />
<GridViewColumn Header="Total Records" Width="100" DisplayMemberBinding="{Binding TotalRecords}" />
<GridViewColumn Header="Records Imported" Width="100" DisplayMemberBinding="{Binding TotalRecordsImported}" />
<GridViewColumn Header="Status" Width="100" DisplayMemberBinding="{Binding Status}" />
<GridViewColumn Header="Records To Import" Width="100">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBox Width="70" Name="txtRecordsToImport" Text="{Binding RecordsToImport}"></TextBox>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="Import" Width="70">
<GridViewColumn.CellTemplate>
<DataTemplate>
<Button Click="Import_Click">Import</Button>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
我该怎么做。
答案 0 :(得分:0)
有两种不同的方法可以设置GridViewColumn的可见性。