You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a page ItemsPage that has a DataGrid with items. What I'm trying to do is when user clicks on the data grid item to create a new view, ItemDetailsPage and add it to the navigation list, so user have multiple items opened.
I've managed to add the new item in the navigation page, but I can't bind the Page with ViewModel to the navigation button.
This is the code to add new item to navigation panel: (It can be better but this is just for testing the ideea)
As you can see you can also close the items that were opened.
System.Windows.Controls.Grid grid = new System.Windows.Controls.Grid();
grid.Children.Add(new System.Windows.Controls.TextBlock()
{
Text = "test",
HorizontalAlignment = HorizontalAlignment.Left,
VerticalAlignment = VerticalAlignment.Center,
});
Button closeBtn = new Button()
{
Icon = new SymbolIcon { Symbol = SymbolRegular.Dismiss24 },
HorizontalAlignment = HorizontalAlignment.Right,
BorderThickness = new Thickness(0),
Background = Colors.Transparent.ToBrush(),
};
closeBtn.Click += CloseBtn_Click;
grid.Children.Add(closeBtn);
NavigationViewItem item = new NavigationViewItem()
{
Content = grid,
TargetPageType = typeof(Views.Pages.ItemDetailsPage)//I guess the binding should be done here?
};
ObservableCollection<NavigationViewItem> items = (ObservableCollection<NavigationViewItem>)MenuItems[1].MenuItemsSource!;
MenuItems[1].MenuItemsSource = new ObservableCollection<NavigationViewItem>(items)
{
item
};
ItemDetailsPage.xaml.cs
public partial class DocumentDetailsPage : Page
{
public DocumentDetailsPage(string id)
{
InitializeComponent();
}
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I have a page
ItemsPage
that has aDataGrid
with items. What I'm trying to do is when user clicks on the data grid item to create a new view,ItemDetailsPage
and add it to the navigation list, so user have multiple items opened.I've managed to add the new item in the navigation page, but I can't bind the
Page
withViewModel
to the navigation button.This is the code to add new item to navigation panel: (It can be better but this is just for testing the ideea)
As you can see you can also close the items that were opened.
ItemDetailsPage.xaml.cs
Beta Was this translation helpful? Give feedback.
All reactions