This is a migrated thread and some comments may be shown as answers.

Selected RadPanelBarItem not expanded after confirmation at PreviewSelectionChanged

4 Answers 99 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
Rainer
Top achievements
Rank 1
Rainer asked on 19 Sep 2011, 11:04 AM

Hello,

in my simple example i have a RadPanelBar with three RadPanelBarItems.
The default behavior of the items is to expand on selection. This is fine for me.

Now I want the user to confirm the change of the selection of the RadPanelBarItems.
Therefore I use a MessageBox in the PreviewSelectionChanged event of the RadPanelBar.

The confirmation logic works fine but the selected item is not expanded after confirmation.
This behavior is different to the default.

Regards
Rainer

The sample code:

<Window x:Class="RadPanelBarItemSelection.MainWindow"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <telerik:RadPanelBar x:Name="pbItems" 
                             ScrollViewer.HorizontalScrollBarVisibility="Auto"
                             ScrollViewer.VerticalScrollBarVisibility="Auto"
                             SelectionMode="Single"
                             IsExpandOnSingleClickEnabled="True"
                             PreviewSelectionChanged="pnlEditorialSysItems_PreviewSelectionChanged">
              
            <telerik:RadPanelBarItem Header="Item1">
                <Border Background="Blue" Height="100">
                    <TextBlock Text="Item1"/>
                </Border>
            </telerik:RadPanelBarItem>
  
            <telerik:RadPanelBarItem Header="Item2">
                <Border Background="Red" Height="100">
                    <TextBlock Text="Item2"/>
                </Border>
            </telerik:RadPanelBarItem>
  
            <telerik:RadPanelBarItem Header="Item3">
                <Border Background="Green" Height="100">
                    <TextBlock Text="Item3"/>
                </Border>
            </telerik:RadPanelBarItem>
        </telerik:RadPanelBar>
    </Grid>
</Window>

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Telerik.Windows.Controls;
  
namespace RadPanelBarItemSelection {
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window {
        public MainWindow() {
            InitializeComponent();
        }
  
        private void pnlEditorialSysItems_PreviewSelectionChanged(object sender, SelectionChangedEventArgs e) {
            if (MessageBoxResult.Yes == MessageBox.Show("Cancel selection ?", "Cancel", MessageBoxButton.YesNo, MessageBoxImage.Question)) {
                e.Handled = true;
            }
        }
    }
}



4 Answers, 1 is accepted

Sort by
0
Petar Mladenov
Telerik team
answered on 22 Sep 2011, 10:14 AM
Hi Rainer,

This could be a focus-related issue caused by the MessageBox.
You can expand the item like so:

private void pnlEditorialSysItems_PreviewSelectionChanged(object sender, SelectionChangedEventArgs e)
      {
          if (MessageBoxResult.Yes == MessageBox.Show("Cancel selection ?", "Cancel", MessageBoxButton.YesNo, MessageBoxImage.Question))
          {
              e.Handled = true;
          }
          else
          {
              if (e.AddedItems.Count > 0)
              {
                  RadTreeViewItem item = e.AddedItems[0] as RadTreeViewItem;
                  item.IsExpanded = true;
              }
          }
      }
 Please let us know if this helps you. Best wishes,
Petar Mladenov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Rainer
Top achievements
Rank 1
answered on 23 Sep 2011, 12:30 PM
Hello Petar,

your suggested solution works fine in the test project.
Unfortunately in the "real world" application IsExpanded gets inverted at HandleClick of TreeViewItem.
After this the TreeViewItem is collapsed again.

I would be glad if you have any suggestions on this issue.

Regards
Rainer

-> RadTreeViewItem.Events.cs - Method HandleClick()
...
if (mustExpandOnSingleClick && !hasDoubleClickOccured && (!isClickAllowed.HasValue || isClickAllowed.Value))
{
this.IsExpanded = !this.IsExpanded;
}
...

-> StackTrace

Telerik.Windows.Controls.Navigation.dll!Telerik.Windows.Controls.RadTreeViewItem.HandleClick() Line 1023    C#
Telerik.Windows.Controls.Navigation.dll!Telerik.Windows.Controls.RadTreeViewItem.OnHeaderMouseLeftButtonUp(object sender = {System.Windows.Controls.Grid}, System.Windows.Input.MouseEventArgs e = {System.Windows.Input.MouseButtonEventArgs}) Line 1606   C#
PresentationCore.dll!System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(System.Delegate genericHandler, object genericTarget) + 0x31 bytes   
PresentationCore.dll!System.Windows.RoutedEventArgs.InvokeHandler(System.Delegate handler, object target) + 0x29 bytes 
PresentationCore.dll!System.Windows.RoutedEventHandlerInfo.InvokeHandler(object target, System.Windows.RoutedEventArgs routedEventArgs) + 0x3e bytes   
PresentationCore.dll!System.Windows.EventRoute.InvokeHandlersImpl(object source = {System.Windows.Controls.Grid}, System.Windows.RoutedEventArgs args = {System.Windows.Input.MouseButtonEventArgs}, bool reRaised = true) + 0xbe bytes
PresentationCore.dll!System.Windows.UIElement.ReRaiseEventAs(System.Windows.DependencyObject sender = {System.Windows.Controls.Grid}, System.Windows.RoutedEventArgs args = {System.Windows.Input.MouseButtonEventArgs}, System.Windows.RoutedEvent newEvent) + 0x114 bytes
PresentationCore.dll!System.Windows.UIElement.OnMouseUpThunk(object sender, System.Windows.Input.MouseButtonEventArgs e) + 0xc5 bytes  
PresentationCore.dll!System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(System.Delegate genericHandler, object genericTarget) + 0x31 bytes   
PresentationCore.dll!System.Windows.RoutedEventArgs.InvokeHandler(System.Delegate handler, object target) + 0x29 bytes 
PresentationCore.dll!System.Windows.RoutedEventHandlerInfo.InvokeHandler(object target, System.Windows.RoutedEventArgs routedEventArgs) + 0x3e bytes   
PresentationCore.dll!System.Windows.EventRoute.InvokeHandlersImpl(object source = {System.Windows.Controls.TextBlock}, System.Windows.RoutedEventArgs args = {System.Windows.Input.MouseButtonEventArgs}, bool reRaised = false) + 0xbe bytes  
PresentationCore.dll!System.Windows.UIElement.RaiseEventImpl(System.Windows.DependencyObject sender = {System.Windows.Controls.TextBlock}, System.Windows.RoutedEventArgs args = {System.Windows.Input.MouseButtonEventArgs}) + 0x79 bytes 
PresentationCore.dll!System.Windows.UIElement.RaiseTrustedEvent(System.Windows.RoutedEventArgs args = {System.Windows.Input.MouseButtonEventArgs}) + 0x41 bytes
PresentationCore.dll!System.Windows.UIElement.RaiseEvent(System.Windows.RoutedEventArgs args, bool trusted) + 0x2c bytes   
PresentationCore.dll!System.Windows.Input.InputManager.ProcessStagingArea() + 0x1ff bytes  
PresentationCore.dll!System.Windows.Input.InputManager.ProcessInput(System.Windows.Input.InputEventArgs input) + 0x45 bytes
PresentationCore.dll!System.Windows.Input.InputProviderSite.ReportInput(System.Windows.Input.InputReport inputReport) + 0x62 bytes 
PresentationCore.dll!System.Windows.Interop.HwndMouseInputProvider.ReportInput(System.IntPtr hwnd, System.Windows.Input.InputMode mode, int timestamp, System.Windows.Input.RawMouseActions actions, int x, int y, int wheel) + 0x2c2 bytes
PresentationCore.dll!System.Windows.Interop.HwndMouseInputProvider.FilterMessage(System.IntPtr hwnd = 657448, MS.Internal.Interop.WindowMessage msg = WM_LBUTTONUP, System.IntPtr wParam = 0, System.IntPtr lParam = 4522048, ref bool handled = false) + 0x67d bytes  
PresentationCore.dll!System.Windows.Interop.HwndSource.InputFilterMessage(System.IntPtr hwnd = 657448, int msg = 514, System.IntPtr wParam = 0, System.IntPtr lParam = 4522048, ref bool handled = false) + 0x75 bytes 
WindowsBase.dll!MS.Win32.HwndWrapper.WndProc(System.IntPtr hwnd = 657448, int msg = 514, System.IntPtr wParam = 0, System.IntPtr lParam = 4522048, ref bool handled = false) + 0xbe bytes  
WindowsBase.dll!MS.Win32.HwndSubclass.DispatcherCallbackOperation(object o) + 0x7d bytes   
WindowsBase.dll!System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate callback, object args, int numArgs) + 0x53 bytes
WindowsBase.dll!MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(object source = {System.Windows.Threading.Dispatcher}, System.Delegate method, object args, int numArgs, System.Delegate catchHandler = null) + 0x42 bytes
WindowsBase.dll!System.Windows.Threading.Dispatcher.InvokeImpl(System.Windows.Threading.DispatcherPriority priority, System.TimeSpan timeout, System.Delegate method, object args, int numArgs) + 0xb4 bytes   
WindowsBase.dll!MS.Win32.HwndSubclass.SubclassWndProc(System.IntPtr hwnd = 657448, int msg = 514, System.IntPtr wParam = 0, System.IntPtr lParam = 4522048) + 0x104 bytes  
[Native to Managed Transition] 
[Managed to Native Transition] 
WindowsBase.dll!System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame frame = {System.Windows.Threading.DispatcherFrame}) + 0xc1 bytes
WindowsBase.dll!System.Windows.Threading.Dispatcher.PushFrame(System.Windows.Threading.DispatcherFrame frame) + 0x49 bytes 
PresentationFramework.dll!System.Windows.Application.RunDispatcher(object ignore) + 0x5b bytes 
PresentationFramework.dll!System.Windows.Application.RunInternal(System.Windows.Window window) + 0x74 bytes
PresentationFramework.dll!System.Windows.Application.Run(System.Windows.Window window) + 0x2b bytes
PresentationFramework.dll!System.Windows.Application.Run() + 0x1b bytes
Shell.exe!Shell.App.Main() + 0x5e bytes C#
[Native to Managed Transition] 
[Managed to Native Transition] 
mscorlib.dll!System.AppDomain.nExecuteAssembly(System.Reflection.RuntimeAssembly assembly, string[] args) + 0x9 bytes  
mscorlib.dll!System.Runtime.Hosting.ManifestRunner.Run(bool checkAptModel) + 0x6e bytes
mscorlib.dll!System.Runtime.Hosting.ManifestRunner.ExecuteAsAssembly() + 0x90 bytes
mscorlib.dll!System.Runtime.Hosting.ApplicationActivator.CreateInstance(System.ActivationContext activationContext, string[] activationCustomData) + 0x65 bytes
mscorlib.dll!System.Runtime.Hosting.ApplicationActivator.CreateInstance(System.ActivationContext activationContext) + 0xd bytes
mscorlib.dll!System.Activator.CreateInstance(System.ActivationContext activationContext) + 0x44 bytes  
Microsoft.VisualStudio.HostingProcess.Utilities.dll!Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone() + 0x23 bytes  
mscorlib.dll!System.Threading.ThreadHelper.ThreadStart_Context(object state) + 0x63 bytes  
mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool ignoreSyncCtx) + 0xb0 bytes   
mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) + 0x2c bytes   
mscorlib.dll!System.Threading.ThreadHelper.ThreadStart() + 0x44 bytes  




0
Petar Mladenov
Telerik team
answered on 28 Sep 2011, 03:18 PM
Hello Rainer,

 Could you please share some more info on the differences in the RadPanelBars from your "real-world"application and the test project used in this thread? This way we could investigate this better. Thank you in advance for your cooperation.

All the best,
Petar Mladenov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Rainer
Top achievements
Rank 1
answered on 29 Sep 2011, 11:04 AM
Hello Petar,

I think the point is the we use Prism to register the single RadOutlookBarItems in the RadOutlookBar.
Actually we changed the workflow to workaround this issue. Unfortunately a further investigation in not planned at the moment.

Regards
Rainer
Tags
PanelBar
Asked by
Rainer
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
Rainer
Top achievements
Rank 1
Share this question
or