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
2370
NullReferenceException when retemplating PaneTabItem and setting IsEnabled on a Button inside
posted

Removing IsEnabled fixes this bug, but I thought I would report this.

Long story short: 

I needed to be able to rename tabs in the XamDockManager and so I had to retemplate the PaneTabItem.  You will see that most of the changes are on the elements named "NormalContent" and "NormalContentBold".  One I changed to be a TextBox so users can edit the tab header on double-click.  I also added a delete icon in the tab header so users can delete the tab.

When the user is in edit mode (TextBox is visible), I disable the delete button (and other buttons in my real project) so that the user knows that they need to finish their rename operation before they can perform any other actions.  I have some restrictions on the naming of the tabs (can't be blank, too many characters, unique).  

The reproduction of the bug is to:

  1. Enter edit mode in the tab header via double-click
  2. Delete the text in the TextBox.
  3. Click on the disabled delete icon.
  4. Message box will popup, Click OK.
  5. Message box then comes up again and null reference exception occurs.

In MainWindow.xaml lines 137-173, you will see the setting that causes the issue.  Setting "IsEnabled" on my delete Button somehow blows it up.

I will just remove IsEnabled for now, but it would be nice for me to have the desired behavior work.

Let me know if you have any questions.

Thanks,

Jon

case7390.zip
Parents
  • 16495
    Offline posted

    Hello Jon,

     

    Thank you for your post.

     

    I have logged this behavior with our developers in our tracking system, with an issue ID of 212618.  I have also created a support ticket on your behalf with number CAS-168688-Z8H8S2 in order to link the development issue to it so that you are automatically updated when a Service Release containing your fix is available for download.

     

    What I can suggest in order to avoid this exception, while our developers investigate your issue is to cancel the mouse capture asynchronously in your LostFocus event after showing the messagebox for example:  

                               m_bDontShowUniqueAnalysisRunMessage = true;

                               MessageBox.Show(this, "Analysis run labels cannot be blank.", "Caption", MessageBoxButton.OK, MessageBoxImage.Information);

                               m_bDontShowUniqueAnalysisRunMessage = false;

                               tb.Focus();

     

                               this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() =>

                               {

                                      if (Mouse.Captured != null)

                                             Mouse.Captured.ReleaseMouseCapture();

                               }));

     

     

    Thank you for using Infragistics components.

Reply Children
No Data