private void okButton_Click(object sender, RoutedEventArgs e) { string flyoutCategoryName = Mytextbox.Text; if (!string.IsNullOrEmpty(flyoutCategoryName)) { MenuItemFactory.addCategory(MenuItems, flyoutCategoryName); PhotoItemFactory.addCategory(flyoutCategoryName); PhotoItemFactory.getPhotoItemsByCategory(flyoutCategoryName, PhotoItems); TitleTextBlock.Text = flyoutCategoryName; BackButton.Visibility = Visibility.Visible; Category = flyoutCategoryName; PhotoItemFactory.getAllLists(MenuItemsWithoutFavourites); //Hassan updated NEW foreach (var p in MenuItems) //Hassan added NEW { if (p.Category.Length > 10) { splitViewPaneLength = ((p.Category.Length) * 15).ToString(); } } AddCategoryButton.Flyout.Hide(); } }