protected override void OnInitialized() { base.OnInitialized(); BackgroundColor = Options.BackgroundColor; textColor = Options.TextColor; Func <string, bool> matchFunc = TopMenu.Match; if (matchFunc == null) { matchFunc = route => { var uri = new Uri(NavigationManager.Uri); var paths = uri.LocalPath.Split('/').Where(x => !string.IsNullOrWhiteSpace(x)).ToArray(); var menuPaths = route.Split('/').Where(x => !string.IsNullOrWhiteSpace(x)).ToArray(); if (paths.Length != menuPaths.Length) { return(false); } for (int i = 0; i < paths.Length; i++) { if (paths[i].ToUpper() != menuPaths[i].ToUpper()) { return(false); } } return(true); }; } if (Options.DefaultActiveIndex == Index || matchFunc(Route)) { TopMenu.ActivateItem(this); } }
public async Task OnClickAsync() { if (ParentMenu != null && TopMenu.Mode == MenuMode.Horizontal) { await ParentMenu.CloseAsync(); } TopMenu.ActivateItem(this); if (!string.IsNullOrEmpty(Route)) { if (OnRouteChanging.HasDelegate) { var arg = new BChangeEventArgs <string>(); arg.NewValue = Route; arg.OldValue = currentRoute; await OnRouteChanging.InvokeAsync(arg); if (arg.DisallowChange) { return; } } NavigationManager.NavigateTo(Route); NavigationManager.LocationChanged += NavigationManager_LocationChanged; } }
public void OnClick() { if (!string.IsNullOrEmpty(Route)) { navigationManager.NavigateTo(Route); } TopMenu.ActivateItem(this); }
protected override void OnInitialized() { base.OnInitialized(); BackgroundColor = Options.BackgroundColor; textColor = Options.TextColor; if (Options.DefaultActiveIndex == Index) { TopMenu.ActivateItem(this); } }
protected override void OnInitialized() { base.OnInitialized(); Func<string, bool> matchFunc = TopMenu.Match; if (matchFunc == null) { matchFunc = DefaultMenuMatcher; } if ((!string.IsNullOrWhiteSpace(Options.DefaultActiveIndex) && Options.DefaultActiveIndex == Index) || matchFunc(Route)) { TopMenu.ActivateItem(this); } }
public void OnClick() { if (ParentMenu != null && TopMenu.Mode == MenuMode.Horizontal) { _ = ParentMenu.CloseAsync(); } if (!string.IsNullOrEmpty(Route)) { navigationManager.NavigateTo(Route); } TopMenu.ActivateItem(this); }
protected override void OnParametersSet() { base.OnParametersSet(); Func<string, bool> matchFunc = TopMenu.Match; if (matchFunc == null) { matchFunc = DefaultMenuMatcher; } if (matchFunc(Route)) { TopMenu.ActivateItem(this); } if (!string.IsNullOrWhiteSpace(BackgroundColor)) { return; } BackgroundColor = Options.BackgroundColor; TextColor = Options.TextColor; }