Skip to content

Commit

Permalink
Example code for HyperlinkButton
Browse files Browse the repository at this point in the history
  • Loading branch information
NotYoojun committed Nov 4, 2024
1 parent 8d9e9e8 commit 649a026
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,36 +14,26 @@
<StackPanel>
<local:ControlExample x:Name="Example1" HeaderText="A hyperlink button that navigates to a URI.">
<local:ControlExample.Example>
<ui:HyperlinkButton
x:Name="Control1"
Content="Microsoft home page"
<ui:HyperlinkButton x:Name="Control1"
Content="iNKORE Studios home page"
IsEnabled="{Binding IsChecked, ElementName=DisableControl1, Mode=OneWay, Converter={StaticResource BoolNegationConverter}}"
NavigateUri="http://www.microsoft.com" />
NavigateUri="http://www.inkore.net" />
</local:ControlExample.Example>
<local:ControlExample.Options>
<StackPanel>
<CheckBox x:Name="DisableControl1" Content="Disable hyperlink button" />
<CheckBox x:Name="DisableControl1" Content="Disable hyperlink button" Click="DisableControl1_Click"/>
</StackPanel>
</local:ControlExample.Options>
<local:ControlExample.Xaml>
<sys:String>
&lt;ui:HyperlinkButton Content=&quot;Microsoft home page&quot; NavigateUri=&quot;http://www.microsoft.com&quot; $(IsEnabled)/&gt;
</sys:String>
</local:ControlExample.Xaml>
</local:ControlExample>

<local:ControlExample HeaderText="A hyperlink button that handles a Click event.">
<local:ControlExample x:Name="Example2" HeaderText="A hyperlink button that handles a Click event.">
<local:ControlExample.Example>
<ui:HyperlinkButton
x:Name="Control2"
Click="GoToHyperlinkButton_Click"
RaiseHyperlinkClicks="False"
Content="Go to ToggleButton" />
</local:ControlExample.Example>
<local:ControlExample.Xaml>
<sys:String>
&lt;ui:HyperlinkButton Content=&quot;ToggleButton&quot; Click=&quot;HyperlinkButton_Click&quot;/&gt;
</sys:String>
</local:ControlExample.Xaml>
</local:ControlExample>
</StackPanel>
</ui:Page>
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,37 @@ private void Page_Loaded(object sender, RoutedEventArgs e)
});
ObservableCollection<ControlExampleSubstitution> Substitutions = new ObservableCollection<ControlExampleSubstitution>() { Substitution };
Example1.Substitutions = Substitutions;

UpdateExampleCode();
}

private void DisableControl1_Click(object sender, RoutedEventArgs e)
{
UpdateExampleCode();
}

#region Example Code

public void UpdateExampleCode()
{

Example1.Xaml = Example1Xaml;
Example2.Xaml = Example2Xaml;
}

#endregion
public string Example1Xaml => $@"
<ui:HyperlinkButton x:Name=""Control1""
Content=""iNKORE Studios home page""
IsEnabled=""{Control1.IsEnabled}""
NavigateUri=""http://www.inkore.net"" />
";

public string Example2Xaml => $@"
<ui:HyperlinkButton x:Name=""Control2""
Click=""GoToHyperlinkButton_Click""
RaiseHyperlinkClicks=""False""
Content=""Go to ToggleButton"" />
";

#endregion
}
}

0 comments on commit 649a026

Please sign in to comment.