How to stop Scroll changed event from triggering on data binding (WPF)

Moree Design

                </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

Joe

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.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to stop scroll event from propagating with javascript?

From Dev

Data Binding, Property Changed Event

From Dev

stop blur event from triggering as a result of keypress

From Dev

Triggering an event from ItemsControl (WPF MVVM)

From Dev

How to stop Alt from triggering Global Menu?

From Dev

How to remove data-target and data-toggle from child elements or disable elements from triggering the event?

From Dev

How to save data without triggering an event

From Dev

WPF Data Binding From UserControl

From Dev

Stop Triggering Event on Page Load

From Dev

Stop Triggering Event on Page Load

From Dev

WPF: How to created a routed event for content changed?

From Dev

How to setup data binding in WPF

From Dev

Binding scroll event to iframe

From Dev

Binding scroll event to iframe

From Dev

SAPUI5 Data Binding get the value changed in change event

From Dev

Event triggering from iframe

From Dev

Cancel auto triggering value changed event for UISwitch

From Dev

How to stop Mouseleave from triggering on elements that appear over target?

From Dev

how to stop wifi module triggering from udevadm trigger?

From Dev

How to stop window.scroll() after specific event?

From Dev

How can I stop $(window).scroll event with jquery?

From Dev

How to detect changed of a input from javascript event

From Dev

WPF datagrid combobox column: how to manage event of selection changed?

From Dev

How to use cellEditEnding or current cell changed event in WPF?

From Dev

How to use data binding in WPF C#?

From Dev

WPF - how to use multiple data context for binding

From Dev

WPF SelectionChange Event for ComboBox with Binding from database crashes the Program

From Dev

How to use data binding for Switch onCheckedChageListener event?

From Dev

How do I stop triggering my event-based VBA code when there's an error in the spreadsheet?

Related Related

  1. 1

    How to stop scroll event from propagating with javascript?

  2. 2

    Data Binding, Property Changed Event

  3. 3

    stop blur event from triggering as a result of keypress

  4. 4

    Triggering an event from ItemsControl (WPF MVVM)

  5. 5

    How to stop Alt from triggering Global Menu?

  6. 6

    How to remove data-target and data-toggle from child elements or disable elements from triggering the event?

  7. 7

    How to save data without triggering an event

  8. 8

    WPF Data Binding From UserControl

  9. 9

    Stop Triggering Event on Page Load

  10. 10

    Stop Triggering Event on Page Load

  11. 11

    WPF: How to created a routed event for content changed?

  12. 12

    How to setup data binding in WPF

  13. 13

    Binding scroll event to iframe

  14. 14

    Binding scroll event to iframe

  15. 15

    SAPUI5 Data Binding get the value changed in change event

  16. 16

    Event triggering from iframe

  17. 17

    Cancel auto triggering value changed event for UISwitch

  18. 18

    How to stop Mouseleave from triggering on elements that appear over target?

  19. 19

    how to stop wifi module triggering from udevadm trigger?

  20. 20

    How to stop window.scroll() after specific event?

  21. 21

    How can I stop $(window).scroll event with jquery?

  22. 22

    How to detect changed of a input from javascript event

  23. 23

    WPF datagrid combobox column: how to manage event of selection changed?

  24. 24

    How to use cellEditEnding or current cell changed event in WPF?

  25. 25

    How to use data binding in WPF C#?

  26. 26

    WPF - how to use multiple data context for binding

  27. 27

    WPF SelectionChange Event for ComboBox with Binding from database crashes the Program

  28. 28

    How to use data binding for Switch onCheckedChageListener event?

  29. 29

    How do I stop triggering my event-based VBA code when there's an error in the spreadsheet?

HotTag

Archive