0
약 10 개의 항목이있는 ListBox를 표시하려고합니다. List
에 항목을 추가하여 업데이트 할 때마다 조금씩 눈에 띄는 지연이 발생하고 UI가 잠시 멈 춥니 다. 또한 List
대신 ItemsSource
으로 ObservableCollection
을 사용해 보았습니다. 문제가 해결되지 않았습니다.ListBox를 업데이트하면 지연이 발생합니다.
내 ListBox는 정말 빨리 업데이트해야하므로 정말 도와주세요.
public partial class MainPage : PhoneApplicationPage
{
//private List<Word> Words = new List<Word>();
ObservableCollection<Word> Words = new ObservableCollection<Word>();
// Konstruktor
public MainPage()
{
InitializeComponent();
}
private void button1_Click(object sender, RoutedEventArgs e)
{
ListBox1.ItemsSource = Words;
for (int j = 0; j < 10; j++)
{
Words.Add(new Word(j.ToString()));
}
}
}
public class Word
{
public String sWord { get; set; }
public Word(String word)
{
this.sWord = word;
}
}
XAML
<ListBox Name="ListBox1">
<ListBox.ItemTemplate>
<DataTemplate>
<Button Content="{Binding sWord}" />
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
은 목록에 표시되는 DataTemplate/클래스를 보여줍니다. 컨버터/로직이 너무 많으면 성능이 좋지 않습니다. –
게시물을 업데이트했습니다. 정말 많은 코드가 아닙니다. – Stacksatty
항목을 어떻게 추가 하시겠습니까? –