</ItemsControl.ItemTemplate>
<ItemsControl.GroupStyle>
<GroupStyle>
<GroupStyle.ContainerStyle>
<Style TargetType="GroupItem">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="GroupItem">
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" HorizontalAlignment="Center" FontWeight="Bold" Foreground="{StaticResource Accent}" Text="{Binding Path=Name , StringFormat={}{0:D}}" />
<ItemsPresenter Grid.Row="1"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</GroupStyle.ContainerStyle>
</GroupStyle>
</ItemsControl.GroupStyle>
</ItemsControl>
<Interactivity:Interaction.Triggers>
<Interactivity:EventTrigger EventName="ScrollChanged" >
<Presentation:InvokeDelegateCommandAction Command="{Binding ChatScrollViewer_OnViewChange}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=InvokeParameter}" />
</Interactivity:EventTrigger>
</Interactivity:Interaction.Triggers>
</ScrollViewer>
private void ChatScrollViewer_OnViewChangeEvent(ScrollChangedEventArgs Event)
{
ScrollViewer scrollViewer = Event.OriginalSource as ScrollViewer;
if (scrollViewer.VerticalOffset == 0)
{
}
}
When data binding take place scroll changed event is triggered . How check that this is a trigger from data binding and do nothing and when triggered manually do something
When the binding is updated, is it the ItemsSource of the scroll viewer?
Chances are the binding is adding or removing something, resulting in the scroll viewer changing the size of it's content. Take a look at the scroll changed event args, there's lot of conditions that trigger this event.
You probably only want to check the event properties like:
VerticalChange - Gets a value that indicates the change in vertical offset of a ScrollViewer.
So try only performing your action when VerticalChange != 0. Or drop a debugger in there and see if there's any specific event types you want to ignore that only happen when binding changes, for example:
ExtentHeightChange - Gets a value that indicates the change in height of the ScrollViewerextent.
Might only be none-zero when the binding has updated, making the scroll bar bigger (but not changing the scroll position).
So something like this:
private void ChatScrollViewer_OnViewChangeEvent(ScrollChangedEventArgs Event)
{
if (Event.VerticalChange != 0)
{
ScrollViewer scrollViewer = Event.OriginalSource as ScrollViewer;
if (scrollViewer.VerticalOffset == 0)
{
}
}
}
Hope that helps.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments