RadBradCrumb is a nice idea, but seems to be not really finished.
First, there is no documentation at all.
This little page gives a hint, this thing exists, not more.
https://docs.telerik.com/devtools/winforms/treeview/breadcrumb
Second, the splitbuttons and the dropdownItems are nice initialized and working,
but the DefaultItem of the SplitButton is not set.
You cannot click on the Button, und go up the hierarchie, the most basic function of a breadcrumb.
You always have this dropdown-things only.
Additionally, the RadBradCrumb is quiet a Closed thing, there are no events to subscribe, no virtual methods to override, just nothing.
I have found a workaround for this, which makes it work es expected, but this should be default functionality.
public class BreadCrumbHandler
{
private RadBreadCrumb crumb;
public BreadCrumbHandler(RadBreadCrumb crumb)
{
this.crumb = crumb;
// there is not other access to the DefaultItem of the SplitButtons in the BreadCrumb
var r = crumb.RootElement.Children.First() as RadBreadCrumbElement;
r.Items.ItemsChanged += BreadCrumb_ItemsChanged;
}
private void BreadCrumb_ItemsChanged(RadItemCollection changed, RadItem target, ItemsChangeOperation operation)
{
if (operation == ItemsChangeOperation.Inserted)
{
RadSplitButtonElement btn = target as RadSplitButtonElement;
if (btn != null)
{
var defaultItem = new RadMenuItem(btn.Text);
defaultItem.Text = btn.Text;
defaultItem.Click += DefaultItem_Click;
btn.DefaultItem = defaultItem;
}
}
else if (operation == ItemsChangeOperation.Clearing)
{
foreach (var item in changed.OfType<
RadSplitButtonElement
>())
{
var menuItem = item.DefaultItem as RadMenuItem;
if (menuItem != null)
menuItem.Click -= DefaultItem_Click;
item.DefaultItem = null;
}
}
else if (operation == ItemsChangeOperation.Removing)
{
RadSplitButtonElement btn = target as RadSplitButtonElement;
if (btn != null)
{
var menuItem = btn.DefaultItem as RadMenuItem;
if (menuItem != null)
menuItem.Click -= DefaultItem_Click;
btn.DefaultItem = null;
}
}
}
private void DefaultItem_Click(object sender, EventArgs e)
{
var menuItem = (RadMenuItem)sender;
var currentNode = crumb.DefaultTreeView.SelectedNode;
while (currentNode != null)
{
if (currentNode.Text == menuItem.Text) // not really safe test, but works as long as Texts are distinct
{
crumb.DefaultTreeView.SelectedNode = currentNode;
return;
}
currentNode = currentNode.Parent;
}
}
}