How to focus and select to the next cell with a ListView when scrolling?

I have a ListView filled with cells and I'd like to scroll to the next cell to have it focused and selected.
My code works to scroll down but the scroll bar is going to far!
How can I reduce the scroll size to each cell, so I can see the focused cell? Is there a better way to implements this?
Here is my code:
documentListView.scrollTo(0);
documentListView.getSelectionModel().select(0);
int indexSize = documentListView.getItems().size();
for (Node node : documentListView.lookupAll(".scroll-bar")) {
  if (node instanceof ScrollBar) {
  final ScrollBar bar = (ScrollBar) node;
  bar.valueProperty().addListener(new ChangeListener<Number>() {
  @Override
  public void changed(ObservableValue<? extends Number> value, Number oldValue, Number newValue) {
  int selectedIndex = documentListView.getSelectionModel().getSelectedIndex();
  if(selectedIndex <= indexSize && listScrollDown(oldValue.floatValue(), newValue.floatValue())) {
     selectedIndex++;
     documentListView.scrollTo(selectedIndex);
     documentListView.getFocusModel().focus(selectedIndex);
     documentListView.getSelectionModel().select(selectedIndex);
Thanks for your help,
Regards

You could set the IsHitTestVisible property of the WebControl to false but then you won be able to interact with the web page:
<awe:WebControl ... IsHitTestVisible="False"/>
Another better option would be to handle the PreviewMouseLeftButtonDown of the WebControl, find the ListBoxItem in the visual tree and then set its IsSelected property like this:
<ListView x:Name="BrowserListview" ItemsSource="{Binding browserCollection}">
<ListView.ItemTemplate>
<DataTemplate>
<VirtualizingStackPanel Orientation="Horizontal">
<awe:WebControl Source="{Binding mySource}" PreviewMouseLeftButtonDown="wc_MouseLeftButtonDown"/>
<Rectangle/>
</VirtualizingStackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
private void wc_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) {
ListViewItem lbi = FindParent<ListViewItem>(sender as DependencyObject);
BrowserListview.UnselectAll();
lbi.IsSelected = true;
private static T FindParent<T>(DependencyObject dependencyObject) where T : DependencyObject {
var parent = VisualTreeHelper.GetParent(dependencyObject);
if (parent == null) return null;
var parentT = parent as T;
return parentT ?? FindParent<T>(parent);
Hope that helps.
Please remember to close your threads by marking helpful posts as answer.

Similar Messages

  • How to carry forward leaves to the next year with out writing PCR

    Hi All,
    Could you please tell me the process steps for quota carry forward from previous year to the next year with out writing a PCR
    Regards
    Sita

    Hi
    Leave balance carry forward

  • How do I get rid of the "bounce" or rubber band effect when scrolling

    How do I get rid of the "bounce" or rubber band effect when scrolling

    Please help Apple recognize that users don't want bouncy scrolling by filing a bug:
    http://www.apple.com/feedback/macosx.html
    If enough people complain, Apple will listen to us.

  • How to leapfrog selected record and going to the next one

    Hi ,
    My DB 11G , OS Linux Redhat ,
    i have a Linux script to read the name of the files listed on the Table , then open those files and save the content on another table , i need to speed up the process by running this script multiple time , so i need to
    read the first record (File name ) then running the script again to check if the record already selected then go to the second record and so on .
    is there any way to check the selected row then leapfrog this record  and going to the next record .
    Im already tried (for update skip locked ) but this will  return ( no row selected message when locked ) and  when running on the 2 Scripts  it will considering it as same session and always will be the same .
    my query is (
    select bi_file_name
    from dbm_cdr_head
    where bi_file_name like 'hd_auto%' and bi_auto_status=35;)
    thanks

    Really its about 1 million file per day ( Telecom CDRS Calls Details Records) updated every minutes , i think its very difficult to keep track by External Tables ,
    thank you for you advice about advanced queuing i will going to read about this new concept for me

  • HT4400 how do you advance to the next page with focus 40 blue

    how do you advance to the next page with focus 40 blue

    Hello,
    To place your own images for previous and next button you need to use the fill feature. Please check the steps below:
    1. Go SlideShow options and Uncheck Edit Together.
    2. Select the next button and click on Fill to open Fill panel.
    3. Click On Add Image and select the image you want to use. Also select the fitting type as "Scale to Fill" or "scale to Fit "and Position as "Center".
    4. Do the same for previous button.
    Regards
    Vivek

  • While running how do I get my podcast to play one song and move to the next and not skip to the next after a few seconds into the song?

    I recently started running and downloaded the Couch to 5K webcasts, while running how do I get my podcast to play one song in it's entirety and move to the next and not skip to the next after a few seconds into the song?  I beleive it's the motion of the running that is causing it, is there a setting I need to change?

    Hello nowrunning,
    Is the "Shake to Shuffle" option turned on in your iPod's settings?  To check, head to Settings -> Music -> Shake to Shuffle and make sure it is set to Off.
    B-rock

  • How can I play only part of a song (stop the song short) during a slideshow in iphoto and fade into the next song?

    I am making a slideshow and I only want to play half of one song and fade into the next. How can I do this?

    You need an slideshow app that gives you more control over the Soundtrack.
    Alternatives to iPhoto's slideshow include:
    iMovie, on every Mac sold.
    Others, in order of price:  PhotoPresenter  $29
    PhotoToMovie  $49.95
    PulpMotion  $129
    FotoMagico $29 (Home version) ($149 Pro version, which includes PhotoPresenter)
    Final Cut Express  $199
    It's difficult to compare these apps. They have differences in capability - some are driven off templates. some aren't. Some have a wider variety of transitions. Others will have excellent audio controls. It's worth checking them out to see what meets your needs.  However, there is no doubt that Final Cut Express is the most capable app of them all. You get what you pay for.

  • I bought a song and after 6 sec. or so it quits playing and goes to the next song. How do i redownload it so i can have the whole song?

    I bought a song and after 6 sec. or so it quits playing and goes to the next song. How do i redownload it so i can have the whole song?

    Delete it, click here, and follow the instructions.
    (114426)

  • Latest update returns error " None of the selected updates could be installed. The update could not be expanded, and may have been corrupted during downloading. The update will be downloaded and checked again the next time that Software Update runs."

    Latest update returns error " None of the selected updates could be installed. The update could not be expanded, and may have been corrupted during downloading. The update will be downloaded and checked again the next time that Software Update runs."

    Which latest update? Details get answers. Rather than using SU, DL and install from http://support.apple.com/downloads/.

  • Music cuts off on three tracks about 30 seconds in and skips to the next. how do i fix it?

    I downloaded an album and the music cuts off on three of the tracks about 30 seconds in and skips to the next. can i fix it, if so how??, i would really like these tracks for when im running and its driving me nuts

    Hey Apollo10,
    That definitely sounds frustrating. If the songs are not playing fully in iTunes, they may need to be redownloaded. After you have redownloaded the songs, they should play fully and you can enjoy them when you go running. If not, please let me know.
    Songs in iTunes may not play back completely
    http://support.apple.com/kb/TS4357
    Symptoms
    Occasionally, if a song purchased from the iTunes Store on a Mac or PC was not downloaded completely, the song may not play back fully. The song may abruptly stop during playback, and iTunes may start playing the next song in your library or playlist.
    Resolution
    If iTunes in the Cloud is available in your country, try the following steps to resolve the issue:
    1. Delete the purchased song that is exhibiting the problem from your iTunes library.
    2. Click on the Purchased link in the iTunes Store to view your previously purchased music.
    3. Download your previously purchased song from this list.
    Note: iTunes in the Cloud, which allows you to download previously purchased songs from the iTunes Store, is not available in every country. Learn if iTunes in the Cloud is offered in your country
    Thanks,
    Matt M.

  • HT1849 I bought the song 'Go the Distance' by Michael Bolton. It said it had completed downloading but when I play my song it stops 1.01 minutes into it and goes onto the next song. How can I fix this?

    I bought the song 'Go the Distance' by Michael Bolton. It said it had completed downloading but when I play my song it stops 1.01 minutes into it and goes onto the next song. How can I fix this?

    It seems like alot of people are having this problem tonight. I dont know how to fix it but i hope apple fixes iTunes soon.

  • Both my boss and I have the iPhone 5C for Verizon.  When I text, I have the little microphone next to the space bar, allowing me to use the speech to text function.  He does not.  How do you turn this on or remedy this problem?

    Both my boss and I have the iPhone 5C for Verizon.  When I text, I have the little microphone next to the space bar, allowing me to use the speech to text function.  He does not.  How do you turn this on or remedy this problem?

    Does your boss have Siri turned ON? See Settings > General > Siri.

  • How to focus and navigate the  UIShell Dynamic Tabs through keyboard

    Hi,
    I am using the UIShell which will have the Dynamic tab concept. Here i need to give the keyboard navigation for focusing and navigating between the Dynamic tabs. I have given By providing the access Key concept, By sending the tab(task flow) title preceding with the & and title am displaying through the textAndAccesKey attribute. But in dynamic tab concept, i should not use this, since am allowing the user can open same task flow more than once(with single accesskey multiple tabs will be there). is there any other possibility of quick access without using the accesskey concept like how the IE and Mozilla tab navigation will works by pressing the CTRL+TAB.
    Regards,
    Brahma...
    Edited by: Brahma on Aug 13, 2010 3:37 AM

    Hi,
    the solution is a bit ore complex, so here's the outline
    1. Create an af:serverListener on the page that can be called to send messages to a managed bean on the server (see chapter 5 of the web developer guide to learn about af:serverListener).
    2. Add the following script to a JS library that you reference from af:resource on the page
    function registerKeyBoardHandler(serverListener, afdocument) {
        _serverListener = serverListener;
        var document = AdfPage.PAGE.findComponentByAbsoluteId(afdocument);
        _document = document;
        for (var i = keyRegistry.length - 1; i >= 0; i--)
          var keyStroke = AdfKeyStroke.getKeyStrokeFromMarshalledString(keyRegistry);
    AdfRichUIPeer.registerKeyStroke(document, keyStroke, callBack);
    function callBack(keyCode) {
    var activeComponentClientId = AdfPage.PAGE.getActiveComponentId();
    //send the marshalled key code to the server listener for the developer
    //to handle the function key in a managed bean method
    var marshalledKeyCode = keyCode.toMarshalledString();
    // {AdfUIComponent} component Component to queue the custom event on
    // {String} name of serverListener
    // {Object} params a set of parameters to include on the event.
    // {Boolean} immediate whether the custom event is "immediate" - which will cause it
    // to be delivered during Apply Request Values on the server, or not immediate, in which
    // case it will be delivered during Invoke Application.
    //Note that if one of the keyboard functions is to create ADF bound rows, immediate must be set
    //to false. There is no option yet for the ClientEvent to be queued for later - InvokeApplication
    //- on the server.
    AdfCustomEvent.queue(_document,_serverListener,{keycode:marshalledKeyCode, activeComponentClientId:activeComponentClientId},false);
    //indicate to the client that the key was handled and that there
    //is no need to pass the event to the browser to handle it
    return true;
    3. The JavaScript file also contains the registry of keys you want to listen for
    var keyRegistry = new Array();
    keyRegistry[0]="F1";
    keyRegistry[1]="F2";
    keyRegistry[2]="F3";
    keyRegistry[3]="F4";
    keyRegistry[11]="alt 2";
    4. on the beforePhase property on the f:view tag of the page, reference a managed bean method like thispublic void registerKeyboardMapping(PhaseEvent phaseEvent) {
    if(phaseEvent.getPhaseId() == PhaseId.RENDER_RESPONSE){
    FacesContext fctx = FacesContext.getCurrentInstance();
    ExtendedRenderKitService erks = Service.getRenderKitService(fctx, ExtendedRenderKitService.class);
    List<UIComponent> childComponents = fctx.getViewRoot().getChildren();
    //First child component in an ADF Faces page - and the only child - is af:document
    //Thus no need to parse the child components and check for their component family
    //type
    String id = ((UIComponent)childComponents.get(0)).getClientId(fctx);
    StringBuffer script = new StringBuffer();
    script.append("window.registerKeyBoardHandler('keyboardToServerNotify','" + id +"')");
    erks.addScript(fctx, script.toString());
    The "keyboardToServerNotify" name is the name my af:serverListener component has
    5. The serverListener defined on the page<af:serverListener type="keyboardToServerNotify"
    method="#{viewScope.keyboardMappingHandler.handleKeyboardEvent}"/>
    The above codes send the marshalled string for all pressed keys (that you have registered) to the server (the method configured for the serverListener. This way you can now on the server handle the keys and the
    component the key is pressed on. To register dynamic tabs in the UI Shell (the part I did not yet implement) is to have a keyboard shortcut to register a key for a tab and then another keyboard shortcut to invoke a
    method (disclosed) on a tab is the registered key is pressed.
    Hope this helps.
    Frank
    Ps.: The full sample is part of my OOW demo (September) which I am currently preparing for. Once OOW is over and the dust has settled, I'll document the full sample and release it on ADF Coder Corner with a sample workspace to try                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • TS1362 I have downloaded the song "Bruises" by Band of Skulls and it plays to about 1.20 remaining and then just stops and goes to the next song. How do you fix this?

    I have downloaded the song "Bruises" by Band of Skulls and it plays to about 1.20 remaining and then just stops and goes to the next song. How do you fix this?

    I removed the song from the itunes library and then added it again, but the same issue still exists.
    I'd report the problem to the iTunes Store, then.
    Log in to the Store. Click on "Account" in your Quick Links. When you're in your Account information screen, go down to Purchase History and click "See all".
    Find the item that is not playing properly. If you can't see "Report a Problem" next to the item, click the "Report a problem" button. Now click the "Report a Problem" link next to the item.

  • Certain songs have started stopping half way through and skipping to the next track, how do i fix?

    Recently I have found the certain songs, and its always the same ones, have started stopping half way thru and skipping to the next track.  Even if I manually try and forward thru to the end of the track they wont go beyond half way. Does anyone else have this issue and are there any fixes?

    I have figured out a fix.  I have deleted the songs in question and then gone to the 'purchased' section in iTunes Store and re-downloaded the tracks and they work fine.  Haven't found a problem on a non-downloaded track yet so not sure what fix would be there.

Maybe you are looking for