I’m following this example for an auto-scrolling behavior on a ListBox on WP7 Mango RC targeting 7.1.
In my Xaml:
<ListBox x:Name="StatusMessages"
Height="100"
ItemsSource="{Binding StatusMessages, Mode=TwoWay}"
DisplayMemberPath="Message"
Grid.Row="3">
<i:Interaction.Behaviors>
<behaviors:ListBoxItemAutoScrollBehavior FoundItem="{Binding FoundItem}" />
</i:Interaction.Behaviors>
</ListBox>
The behavior:
public class ListBoxItemAutoScrollBehavior : Behavior<ListBox>
{
public object FoundItem
{
get { return GetValue(FoundItemProperty); }
set { SetValue(FoundItemProperty, value); }
}
public static readonly DependencyProperty FoundItemProperty = DependencyProperty.Register("FoundItem", typeof (object), typeof (ListBoxItemAutoScrollBehavior), new PropertyMetadata(FoundItemChanged));
private static void FoundItemChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
((ListBoxItemAutoScrollBehavior) d).AssociatedObject.ScrollIntoView(e.NewValue);
}
}
I have a breakpoint set at the FoundItemChanged method and would expect to see it hit when I set FoundItem in my ViewModel and fire NotifyProperyChanged. Only, it doesn’t work, any ideas why or what I might be doing wrong?
Thanks.
update: breakpoints are hit for OnAttached and OnDetaching in the behavior.
update 2: This works in a regular Silveright 4 application.
update 3: Using version 3.8.5.0 of System.Windows.Interactivity fixed it.
Using version 3.8.5.0 of System.Windows.Interactivity fixed this problem.
This post gave me the tip: http://caliburnmicro.codeplex.com/discussions/271092