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 my previous article, i have discuss hyperlinkbutton with XAML code in windows 8 app development. In this article i will explain use this button in c# code file. Write the below code in specified file:
XAML CODE
<Pagex:Class="App4.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:App4"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
<HyperlinkButton x:Name="h1" Height="200" Width="257" Content="Microsoft Development Network" Margin="90,20,0,548" Click="h1_Click" />
</Grid>
</Page>
CODE FILE
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Media.Imaging;
using Windows.UI.Xaml.Navigation;
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
namespace App4
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
//BitmapImage img = new BitmapImage();
//img.UriSource = new Uri(this.BaseUri,"Image/youtube.png");
//Image1.Source = img;
List<string> lit = new List<string>();
lit.Add("Apple");
lit.Add("Apple");
lit.Add("Apple");
lit.Add("Apple");
//l1.ItemsSource = lit;
}
private void h1_Click(object sender, RoutedEventArgs e)
{
Uri uri = new Uri("http://www.msdn.microsoft.com");
h1.NavigateUri = uri;
}
}
}
In the above c# code, look out the click event of hyperlinkbutton h1, i have created an object of Uri class with the link as a constructor's parameter. And then set the property NavigateUri to the object defined above. When user will click on this button, it will redirect programmer to the specified page.
In the above c# code, look out the click event of hyperlinkbutton h1, i have created an object of Uri class with the link as a constructor's parameter. And then set the property NavigateUri to the object defined above. When user will click on this button, it will redirect programmer to the specified page.
OUTPUT
Comments
Post a Comment