Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Sorry, I couldn't reproduce your problem.</p> <p>I started Visual C# 2010 Express, created a new 'WPF Application', added your XAML to a <code>UserControl</code> that I imaginatively titled <code>UserControl1</code>, and added your <code>ItemsControlBehavior</code> class. I then modified the MainWindow that VC# created for me as follows:</p> <p>MainWindow.xaml (contents of <code>&lt;Window&gt;</code> element only):</p> <pre><code>&lt;StackPanel Orientation="Vertical"&gt; &lt;Button Content="Add user control" Click="ButtonAddUserControl_Click" /&gt; &lt;Button Content="Add message" Click="ButtonAddMessage_Click" /&gt; &lt;StackPanel Orientation="Horizontal" x:Name="sp" Height="300" /&gt; &lt;/StackPanel&gt; </code></pre> <p>MainWindow.xaml.cs:</p> <pre><code>public partial class MainWindow : Window { public ObservableCollection&lt;string&gt; Messages { get; private set; } public MainWindow() { InitializeComponent(); Messages = new ObservableCollection&lt;string&gt;() { "1", "2", "3", "4" }; DataContext = this; } private void ButtonAddUserControl_Click(object sender, RoutedEventArgs e) { sp.Children.Add(new UserControl1()); } private void ButtonAddMessage_Click(object sender, RoutedEventArgs e) { Messages.Add((Messages.Count + 1).ToString()); } } </code></pre> <p>I made no modifications to the XAML in your UserControl, nor to your <code>ItemsControlBehavior</code> class.</p> <p>I found that no matter how many user controls were added, their ScrollViewers all scrolled down to the bottom when I clicked the 'Add message' button.</p> <p>If you're only seeing the scroll-to-the-bottom behaviour on one of your user controls, then there must be something that you're not telling us.</p>
    singulars
    1. This table or related slice is empty.
    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.
    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