1
虛擬化樹狀我使用Silverlight工具包樹視圖來顯示數據集。它有1000個元素,一些子元素也有多達500個子元素。加載數據並在樹視圖中顯示需要幾分鐘的時間。樹視圖是否具有虛擬化?如果是這樣,請問有人可以給我一個樣本或代碼片段嗎?在Silverlight
以下是XAML
<controls:TreeView Grid.Column="0" VerticalAlignment="Stretch"
ItemsSource="{Binding People}" >
<controls:TreeView.ItemTemplate>
<common:HierarchicalDataTemplate ItemsSource="{Binding Children}">
<StackPanel>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="10*"/>
<ColumnDefinition Width="90*"/>
</Grid.ColumnDefinitions>
<CheckBox IsChecked="{Binding TwoState}" Grid.Column="0"/>
<TextBlock Grid.Column="1" Text="{Binding Name}"/>
</Grid>
</StackPanel>
</common:HierarchicalDataTemplate>
</controls:TreeView.ItemTemplate>
</controls:TreeView>
以下是個人類我用
public class Person:INotifyPropertyChanged
{
public string Name { get; set; }
public int Age { get; set; }
public bool TwoState { get; set; }
public ObservableCollection<Person> Children { get; set; }
public Person()
{
TwoState = false;
Children = new ObservableCollection<Person>();
}
public event PropertyChangedEventHandler PropertyChanged;
private void NotifyPropertyChanged(string info)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(info));
}
}
}