Breadcrumb.SelectedItem

Navigation for WPF Forum

Posted 15 years ago by Jon Cain - Software Architect, AutoMon Corporation
Version: 4.5.0477
Avatar
I have an issue where I am setting the SelectedItem of a breadcrumb control using standard WPF binding. It sets the selected item correctly, but it does not updated the breadcrumb display to show the correct icon and text, etc. However, if i toggle the breadcrumb control to edit mode, it does display the correct path.

Any assistance would be greatly appreciated.

Thanks.

Comments (7)

Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Jon,

Make sure that you are properly handling the Breadcrumb.ConvertItem event. This event has two functions: to convert an item to/from a string path and to find the trail from an item to the Breadcrumb.RootItem. The latter is used by the Breadcrumb to locate the item in the tree, which sounds like where your problem is at.

If this doesn't help, please put together a small sample project and email it over to our support address and we can take a look.


Actipro Software Support

Posted 15 years ago by Troy Magner
Avatar
I had the same problem and although this solution has helped somewhat I find that the parent items in the selected tree don't appear selected in the menu items. E.G. the MenuItemExpandedTemplate doesn't seem to get applied to those items.

When I set the selected item using the UI however, everything seems fine. It is only when doing it programmatically that things go awry.
Posted 15 years ago by Jon Cain - Software Architect, AutoMon Corporation
Avatar
I had to dispatch the setting of the breadcrumb the first time.

  Dispatcher.Invoke(
    new Action(() => { breadcrumb.SelectedPath=path; }),
    DispatcherPriority.Loaded,
    null);
Actipro is aware of the problem and should fix it in a future release.

[Modified at 06/23/2009 10:44 AM]
Posted 15 years ago by Troy Magner
Avatar
Well, I'm not using the path because where I'm using the breadcrumb component the IsEditable flag is set to false. However, even setting the path to String.Empty doesn't seem to do anything for me.

Dispatching the setting of the Trail property doesn't help either.
Posted 15 years ago by Jon Cain - Software Architect, AutoMon Corporation
Avatar
Try Dispatching set_SelectedItem:

Dispatcher.Invoke(
    new Action(() => { breadcrumb.SelectedItem=myItem; }),
    DispatcherPriority.Loaded,
    null);
Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Troy,

It sounds like you are talking about the ConvertItem event, while Jon is talking about setting the initial root item (either via Path or SelectedItem) before the control is loaded.

The ConvertItem event should not be dispatched, as the resuls are needed immediately. Nor should you try to set the Breadcrumb.SelectedItem or SelectedPath in the handler for this event. I'm not sure if this is what you are doing though.

If you can put together a small sample project and email it over to our support address then we can take a look.


Actipro Software Support

Posted 15 years ago by Troy Magner
Avatar
You're right we were talking about 2 different things. I hadn't even realized.

I did find the problem though. I was setting the SelectedItem to a different instance than was contained in the breadcrumb control. The Equals method for the class had been overridden and whatever logic is actually changing the breadcrumb UI must have been calling Equals while the logic to set the MenuItemExpandedTemplate must be comparing references.

I kept thinking I must have been missing something especially since I wasn’t ever setting the path but no the different object instances were causing the problems all along.
The latest build of this product (v24.1.1) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.