Note that there are some explanatory texts on larger screens.

plurals
  1. POWPF TabControl/ScrollIntoView Issue
    primarykey
    data
    text
    <p>I have a <strong>TabControl</strong> with <strong>two tabs</strong> containing <strong>lists that should always be scrolled to the bottom</strong>:</p> <pre><code> &lt;TabControl&gt; &lt;TabItem Header="Tab1"&gt; &lt;ScrollViewer VerticalScrollBarVisibility="Auto"&gt; &lt;ListBox x:Name="List1"&gt; &lt;ListBox.ItemTemplate&gt; &lt;DataTemplate DataType="SampleClass"&gt; &lt;TextBlock Text="{Binding SampleProperty}" /&gt; &lt;/DataTemplate&gt; &lt;/ListBox.ItemTemplate&gt; &lt;/ListBox&gt; &lt;/ScrollViewer&gt; &lt;/TabItem&gt; &lt;TabItem Header="Tab2"&gt; &lt;ScrollViewer VerticalScrollBarVisibility="Auto"&gt; &lt;ListBox x:Name="List2"&gt; &lt;ListBox.ItemTemplate&gt; &lt;DataTemplate DataType="OtherSampleClass"&gt; &lt;TextBlock Text="{Binding SampleProperty}" /&gt; &lt;/DataTemplate&gt; &lt;/ListBox.ItemTemplate&gt; &lt;/ListBox&gt; &lt;/ScrollViewer&gt; &lt;/TabItem&gt; &lt;/TabControl&gt; </code></pre> <p>Now, I have events set up so that when the binding changes, the following code is executed to scroll to the bottom of the list (depends on the tab, this is an example of what happens when the first list's items are changed):</p> <pre><code>ListBox1.ScrollIntoView(items.Last&lt;SampleClass&gt;()); </code></pre> <p>This works fine. When the binding is changed, the ListBox scrolls to the bottom as expected.</p> <p>However, when I set the same code up to execute when tabs are changed (to scroll to bottom of a list when the tabs change), the lists do not scroll to the bottom as expected (and show up scrolled at the top).</p> <p>I tried hooking into SelectionChanged event of the TabControl. My guess is that the layout isn't yet rendered when this event is executed, so calling ScrollIntoView() does nothing.</p> <p>Is there any way around this?</p> <p>Thanks.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload