The HyperLink Control is the control to link to another page. The HyperLink can navigate to an "URL" as well as an XAML page.
HyperLink properties:
- Background: The background property used to change the background color of the HyperLink control.
- ClickMode: The click mode says when to fire a click event.
- Foreground: It's the property to change color of the font of content.
- Content: Is the content of the control.
- Name: Name of the control.
- Fontfamily: Font type of the HyperLink content.
- Horizontal alignment and vertical alignment: These align the HyperLink control.
- Horizontalcontentalignment and verticalcontentalignment: Aligns the content of the control.
- Click: The click event that is fired when the control is clicked
XAML page :
<UserControl xmlns:input="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Input" x:Class="ControlSamples.MainPage"
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"
mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480">
<ScrollViewer>
<StackPanel Orientation="Vertical">
<StackPanel>
<Grid x:Name="LayoutRoot" Width="1000" Height="100" VerticalAlignment="Top">
<Grid.Background>
<LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
<GradientStop Color="SkyBlue" Offset="0"/>
<GradientStop Color="White" Offset="0.75"/>
<GradientStop Color="SkyBlue" Offset="1"/>
</LinearGradientBrush>
</Grid.Background>
</Grid>
</StackPanel>
<StackPanel Height="500" Width="200" HorizontalAlignment="Left" Margin="0,10,0,0" >
<StackPanel.Background>
<LinearGradientBrush StartPoint="0,0" EndPoint="0.5,1">
<GradientStop Color="SkyBlue" Offset="0"/>
<GradientStop Color="White" Offset="1"/>
</LinearGradientBrush>
</StackPanel.Background>
<HyperlinkButton Background="Yellow" Name="MyHyperlink" ClickMode="Press" Content="AutoCompleteBox" Foreground="Blue" FontFamily="Arial" FontSize="15" Click="HyperlinkButton_Click" ></HyperlinkButton>
</StackPanel>
</StackPanel>
</ScrollViewer>
</UserControl>
The XAML page has the design of the page with the HyperLink Control.
Navigation:
<HyperlinkButton Background="Yellow" Name="MyHyperlink" ClickMode="Press" Content="AutoCompleteBox" Foreground="Blue" FontFamily="Arial" FontSize="15" NavigateUri="http:\\www.google.com">
</HyperlinkButton>
This navigates to the Google page.
Navigation from XAML to another XAML:
<HyperlinkButton Background="Yellow" Name="MyHyperlink" ClickMode="Press" Content="AutoCompleteBox" Foreground="Blue" FontFamily="Arial" FontSize="15" Click="HyperlinkButton_Click" ></HyperlinkButton>
C#
private void HyperlinkButton_Click(object sender, RoutedEventArgs e)
{
this.Content=new Page1();
}
Thank you!!!