'Wpf navigation from one page to another and data grid loading large data
This is the desktop application I am creating in WPF. I am using Hamburger menu library.
I am struggling with this for last one week. I want to replace the container with my view model when i select item from navigation list and that view model contains large number of rows in a data grid. What is the most efficient way to navigate view models and load large number of rows in a data grid.
Here is my code
<Window x:Class="GymateDeskUi.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:GymateDeskUi"
xmlns:controls="http://firstfloorsoftware.com/ModernUI"
mc:Ignorable="d"
xmlns:mui="http://firstfloorsoftware.com/ModernUI"
xmlns:HamburgerMenu="clr-namespace:HamburgerMenu;assembly=HamburgerMenu"
WindowState="Maximized"
Title="MainWindow" MinHeight="500" MinWidth="525" x:Name="this_">
<Grid>
<ProgressBar Orientation="Horizontal" IsIndeterminate="True" Grid.RowSpan="2" Margin="24" x:Name="progress" Visibility="{Binding visibility}"/>
<DockPanel >
<HamburgerMenu:HamburgerMenu Background="#F3F3F3"
MenuIconColor="Black"
SelectionIndicatorColor="#3176BC"
MenuItemForeground="Black" HorizontalAlignment="Left"
DockPanel.Dock="Left">
<HamburgerMenu:HamburgerMenuItem x:Name="enquiry" Icon="Assets/x_board-papper.png" Text="Enquiry" SelectionCommand="{Binding ElementName=this_}" CommandParam="enquiry" />
<HamburgerMenu:HamburgerMenuItem x:Name="member" Icon="Assets/x_user.png" Text="Member" SelectionCommand="{Binding ElementName=this_}" CommandParam="member"/>
<HamburgerMenu:HamburgerMenuItem x:Name="invoice" Icon="Assets/x_paper.png" Text="Invoice" SelectionCommand="{Binding ElementName=this_}" CommandParam="invoice" />
<HamburgerMenu:HamburgerMenuItem x:Name="reciept" Icon="Assets/x_file-success.png" Text="Reciept" SelectionCommand="{Binding ElementName=this_}" CommandParam="reciept"/>
</HamburgerMenu:HamburgerMenu>
<controls:ModernFrame x:Name="Container"></controls:ModernFrame>
</DockPanel>
</Grid>
This is HamburgerMenu.
static HamburgerMenuItem()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(HamburgerMenuItem), new FrameworkPropertyMetadata(typeof(HamburgerMenuItem)));
}
public string Text
{
get {
return (string)GetValue(TextProperty); }
set { SetValue(TextProperty, value); }
}
public static readonly DependencyProperty TextProperty =
DependencyProperty.Register("Text", typeof(string), typeof(HamburgerMenuItem), new PropertyMetadata(String.Empty));
public ImageSource Icon
{
get { return (ImageSource)GetValue(IconProperty); }
set { SetValue(IconProperty, value); }
}
public static readonly DependencyProperty IconProperty =
DependencyProperty.Register("Icon", typeof(ImageSource), typeof(HamburgerMenuItem), new PropertyMetadata(null));
public Brush SelectionIndicatorColor
{
get { return (Brush)GetValue(SelectionIndicatorColorProperty); }
set { SetValue(SelectionIndicatorColorProperty, value); }
}
public static readonly DependencyProperty SelectionIndicatorColorProperty =
DependencyProperty.Register("SelectionIndicatorColor", typeof(Brush), typeof(HamburgerMenuItem), new PropertyMetadata(Brushes.Blue));
public ICommand SelectionCommand
{
get { return (ICommand)GetValue(SelectionCommandProperty); }
set { SetValue(SelectionCommandProperty, value); }
}
public static readonly DependencyProperty SelectionCommandProperty =
DependencyProperty.Register("SelectionCommand", typeof(ICommand), typeof(HamburgerMenuItem), new PropertyMetadata(null));
public string CommandParam
{
get { return (string)GetValue(CommandParamProperty); }
set { SetValue(CommandParamProperty, value); }
}
public static readonly DependencyProperty CommandParamProperty =
DependencyProperty.Register("CommandParam", typeof(string), typeof(HamburgerMenuItem), new PropertyMetadata(null));
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|