I want to show Components in a tabs , so first of all create few components. In this project we have three components, First View Component public class AllViewComponent : ViewComponent { private readonly UserManager<ApplicationUser> _userManager; public AllViewComponent(UserManager<ApplicationUser> userManager) { _userManager = userManager; } public async Task<IViewComponentResult> InvokeAsync() { List<StudentViewModel> allUsers = new List<StudentViewModel>(); var items = await _userManager.Users.ToListAsync(); foreach (var item in items) { allUsers.Add(new StudentViewModel {Id=item.Id, EnrollmentNo = item.EnrollmentNo, FatherName = item.FatherName, Name = item.Name, Age = item.Age, Birthdate = item.Birthdate, Address = item.Address, Gender = item.Gender, Email = item.Email }); }
In previous article we have already learned about Hyperlink Button control. Using the HyperlinkButton control you can navigate one page to another in windows phone. The following example creates a HyperlinkButton control named hyper and then adds it to ContentPanel grid.
Add the following code in the constructor.
C#
public MainPage()
{
InitializeComponent();
HyperlinkButton h1 = new HyperlinkButton();
h1.Content = "My Button";
ContentPanel.Children.Add(h1);
h1.Click += new RoutedEventHandler(HyperlinkButton_Click);
// Sample code to localize the ApplicationBar
//BuildLocalizedApplicationBar();
}
To add the Hyperlink Button control by using code
Open MainPage.xaml.cs.Add the following code in the constructor.
C#
public MainPage()
{
InitializeComponent();
HyperlinkButton h1 = new HyperlinkButton();
h1.Content = "My Button";
ContentPanel.Children.Add(h1);
h1.Click += new RoutedEventHandler(HyperlinkButton_Click);
// Sample code to localize the ApplicationBar
//BuildLocalizedApplicationBar();
}
private void HyperlinkButton_Click(object sender, EventArgs e)
{
NavigationService.Navigate(new Uri("/secondpage.xaml", UriKind.Relative));
}
Create Hyperlink Button control instance , assign string to the content property of Hyperlink Button. Now add this control into Content Panel. When we click on it then page navigate to other page. The name of other page is "secondpage.xaml". So raise click event for that, using NavigationService.Navigate ( ) method you can move one page to another.
Comments
Post a Comment