Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
295
ScreenView in PaneNavigator
posted

The PaneNavigator when clicked it displays number of screens which are opened in the dockmanager  and in the right hand side it displays a view of the screen. By default the first screen is in selected state in the PaneNavigator and view of the screen is displayed in the right hand side of the Panenavigator, when i click on down arrow to select the next screen, the next screen is selected and the view of the screen is also displayed inside the PaneNavigator but when I hover my mouse on a screen the view of the screen is not displayed instead it displays the previous screen. How to display the view of a screen in the PaneNavigator when I just hover on the Screen Name using the mouse. Help me out in solving this issue.

Thanks in Advance!

 

Regards,

LakshmiNarayanan.C

 

Parents
  • 54937
    Suggested Answer
    Offline posted

    Essentially the default template for the PaneNavigator uses 2 listboxes. By default when you hover over an item in the listbox it is rendered as highlighted but that doesn't change the SelectedValue of the ListBox - that's why you'll find that the screen doesn't change and the item that you navigated to with the keyboard is still selected. SInce the selected value isn't changed - it is still the item you navigated to with the keyboard, the screen won't be updated. I don't believe the ListBox has any properties that cause it to update the SelectedValue based on mouse movement. Note, the behavior exhibited in the xamDockManager is the same you will find in VS (at least in 2005/2008 - haven't tested this in 2010).

    In all likelihood if you want this behavior you will need to write your own attached behavior that changes the selection of a listbox when the listbox item gets a mouseenter or when its IsHighlighted is true. Then you would have to create a custom template for the PaneNavigator and use your attached behavior on the listboxes in the panenavigator template. You can use the default xaml we ship in the DefaultStyles directory as a starting point for your custom template.

    After some thought I came up with a relatively simple way to implement this without retemplating:

    public partial class App : Application
    {
    static App()
    {
    EventManager.RegisterClassHandler(typeof(ListBoxItem), Mouse.MouseEnterEvent, new MouseEventHandler(OnMouseEnterListBoxItem));
    }
     
    private static void OnMouseEnterListBoxItem(object sender, MouseEventArgs e)
    {
    ListBoxItem item = sender as ListBoxItem;
     
    // to make this as effecient as possible as this will be invoked for every 
    // listbox item in the application, exit if this is not within a xamdockmanager
    XamDockManager dm = XamDockManager.GetDockManager(item);
     
    if (null == dm)
    return;
     
    // get the containing itemscontrol
    ListBox lb = ItemsControl.ItemsControlFromItemContainer(item) as ListBox;
     
    // if this isn't a listbox or its not within the panenavigator then exit
    if (null == lb || lb.TemplatedParent is PaneNavigator == false)
    return;
     
    // otherwise select the item and give it keyboard focus. the latter is 
    // very important since the "selected" item in the pane navigator is 
    // based upon the keyboard focus since it contains 2 different listboxes
    // each which have their own notion of a selected item
    int index = lb.ItemContainerGenerator.IndexFromContainer(item);
    lb.SelectedIndex = index;
     
    item.Focus();
    }
    }
     

     

Reply Children
No Data