0

I have this touch screen wpf application that uses templates and I need to know when I am at the end of a list using the scrollviewer and the Repeat buttons, I need to have a hook to some C# code I have tried a lot of different things (I am new to wpf) but nothing is working. I think I need to attach to the Collapsed value of the setter. The following is the code segment that I am trying to put my hook into.

<Grid DockPanel.Dock="Bottom" HorizontalAlignment="Stretch" Background="LightCyan" >
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="50*"/>
        <ColumnDefinition Width="auto"/>
        <ColumnDefinition Width="50*"/>               
    </Grid.ColumnDefinitions>
        <Grid.Style>
        <Style TargetType="{x:Type Grid}" >
            <Setter Property="Visibility" Value="Visible"></Setter>
            <Style.Triggers>
                <DataTrigger Value="True">
                    <DataTrigger.Binding>
                        <MultiBinding Converter="{StaticResource areValuesGreaterThanOrEqual}">
                            <Binding ElementName="scrollviewer" Path="VerticalOffset"></Binding>
                            <Binding ElementName="scrollviewer" Path="ScrollableHeight"></Binding>
                        </MultiBinding>                                    
                    </DataTrigger.Binding>
                    <Setter Property="Visibility" Value="Collapsed"></Setter>                              
                </DataTrigger>
            </Style.Triggers>                        
        </Style>
    </Grid.Style>

    <Button x:Name="EndNavigation"
        VerticalAlignment="Center" Content="END" HorizontalAlignment="Right" Grid.Column="0"
        Command="{x:Static ScrollBar.ScrollToBottomCommand}" Margin="5 0 5 0"  
        Style="{StaticResource NavigationBlueButtonStyle}" 
        CommandTarget="{Binding ElementName=scrollviewer}">
    </Button>


    <RepeatButton x:Name="LineDownButton" Width="250" HorizontalAlignment="Center" Grid.Column="1"
        VerticalAlignment="Center" 
        Template="{StaticResource downArrowInBox}"
        Command="{x:Static ScrollBar.LineDownCommand}"      
        CommandTarget="{Binding ElementName=scrollviewer}">
    </RepeatButton>

    <RepeatButton x:Name="PageDownButton" Margin="5 0 0 0" VerticalAlignment="Center" Grid.Column="2"
        HorizontalAlignment="Left" Content="PAGE DOWN"
        Style="{StaticResource NavigationBlueRepeatButtonStyle}" 
        Command="{x:Static ScrollBar.PageDownCommand}"      
        CommandTarget="{Binding ElementName=scrollviewer}">              
    </RepeatButton>
</Grid>
daniele3004
  • 13,072
  • 12
  • 67
  • 75
  • I think you have to do something in codebehind. Technically you have to access the vertical scrollbar, it has the `Value` and `Maximum` properties so you can check if it reaches the end. To use a Trigger, some how it has to listen to `Value` of the inner vertical ScrollBar and compare against the `Maximum`, maybe some converter is needed. I have to say that it's not easy to have a pure XAML solution in this scenario. – King King Nov 13 '14 at 03:23
  • Thank you for the comment. I guess that is what I am really asking how can I accomplish that. I have tried several different solutions that I found on the net but because these controls are written the way they are written non of them work. I think if I can get to the codebehind I should be able to use the maximum value to do what I need to do. – user2697296 Nov 13 '14 at 12:42

0 Answers0