Answer the question
In order to leave comments, you need to log in
How to find out the size of ListBox after adding items?
Need to add to canvas ListBox
Elements in listbox - TextBlock with line wrapping enabled.
Before adding it to the canvas, you need to increase its height by the height of the listbox.
I do not set the height of the listbox hard, because it should depend on the number of elements inside.
After adding elements, how to determine what the height of the listbox will be?
ListBox previewlistBox = new ListBox();
// в цикле добавляем элементы в список
TextBlock v_answer_block = new TextBlock();
v_answer_block.Text = "текст элемента";
v_answer_block.FontWeight = FontWeights.Bold;
previewlistBox.Items.Add(v_answer_block);
//конец цикла
// тут надо определить чему будет равна высота у previewlistBox
// а затем увеличить высоту канвы
preview_canvas.Height = preview_canvas.Height + высота listbox;
previewlistBox.IsEnabled = false;
previewlistBox.Width = preview_canvas.Width;
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question