最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

.NET?MAUI項目中創(chuàng)建超鏈接

 更新時間:2022年03月28日 11:47:06   作者:.NET開發(fā)菜鳥  
這篇文章介紹了.NET?MAUI項目中創(chuàng)建超鏈接的方法,文中通過示例代碼介紹的非常詳細。對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下

.NET MAUI Preview 13預覽版中,.NET MAUI 支持帶標簽控件的格式化文本。

標簽中的格式化文本

標簽是顯示帶或不帶文本環(huán)繞的文本的視圖。使用格式化文本功能(現在位于單個標簽中),您可以使用不同的 span 元素為每個設置選擇多個選項。
例如,您可以對單個標簽中的單詞應用單獨的顏色。這將使標簽更具裝飾性。
Span 元素支持以下選項:

  • CharacterSpacing
  • FontAttributes
  • FontFamily
  • FontSize
  • TextColor
  • TextTransform.Lowercase
  • TextTransform.Uppercase
  • TextDecorations.Underline
  • TextDecorations.Strikethrough
<Label Margin="10" LineHeight="2">
 <Label.FormattedText>
  <FormattedString>
   <Span Text=".NET MAUI Label with Text Formatting in Preview 13 " FontSize="20" />
   <Span Text="Character Spacing - " FontSize="14" TextColor="Black"/>
   <Span Text=" Hello World! " FontSize="14" CharacterSpacing="12" />
   <Span Text="Font Attributes - " FontSize="14" TextColor="Black"/>
   <Span Text=" Hello World! " FontSize="14" FontAttributes="Bold"/>
   <Span Text="Font Size - " FontSize="14" TextColor="Black"/>
   <Span Text=" Hello World! " FontSize="18"/>
   <Span Text="Font Family - " FontSize="14" TextColor="Black"/>
   <Span Text=" Hello World! " FontSize="14" FontFamily="Matura MT Script Capitals" />
   <Span Text="Text Color - " FontSize="14" TextColor="Black"/>
   <Span Text=" Hello World! " FontSize="14" TextColor="Red"/>
   <Span Text="Lowercase - " FontSize="14" TextColor="Black"/>
   <Span Text=" Hello World! " FontSize="14" TextTransform="Lowercase"/>
   <Span Text="Uppercase - " FontSize="14" TextColor="Black"/>
   <Span Text=" Hello World! " FontSize="14" TextTransform="Uppercase" />
   <Span Text="Strikethrough - " FontSize="14" TextColor="Black"/>
   <Span Text=" Hello World! " FontSize="14" TextDecorations="Strikethrough"/>
   <Span Text="Underline - " FontSize="14" TextColor="Black"/>
   <Span Text=" Hello World! " FontSize="14" TextDecorations="Underline" />
  </FormattedString>
 </Label.FormattedText>
</Label>

使用標簽的格式化文本功能創(chuàng)建超鏈接 UI

我將使用兩個選項,TextColor和TextDecorations.Undercomings.Undercoming,創(chuàng)建一個具有超鏈接UI的標簽。

創(chuàng)建可重用超鏈接類

創(chuàng)建了一個名為 HyperlinkUI 的類,該類派生自 span,并在其中添加了一個名為 LinkUrl 的可綁定屬性。
由于 span 繼承了 GestureElement,因此您可以添加 Gesture 識別器以使用 LinkUrl 屬性進行導航。
請參閱下面的代碼示例。

public class HyperlinkUI : Span
{
  public static readonly BindableProperty LinkUrlProperty =
   BindableProperty.Create(nameof(LinkUrl), typeof(string), typeof(HyperlinkUI), null);
  
  public string LinkUrl
  {
    get
    {
      return (string)GetValue(LinkUrlProperty);
    }
    set
    {
      SetValue(LinkUrlProperty, value);
    }
  }

   public HyperlinkUI()
   {
      ApplyHyperlinkAppearance();
   }

   void ApplyHyperlinkAppearance()
   {
      this.TextColor = Color.FromArgb("#0000EE");
      this.TextDecorations = TextDecorations.Underline;
   }

   void CreateNavgigationCommand()
   {
      // 由于 Span 繼承了 GestureElement,因此您可以添加 Gesture Recognizer 以使用 LinkUrl 進行導航
   }
}

現在,您可以將此超鏈接UI用作標簽中的跨度元素。我們可以將整個文本或部分文本顯示為超鏈接文本。請參閱下面的代碼示例。

<Label Margin="10" LineHeight="2" InputTransparent="False" TextColor="Black">
 <Label.FormattedText>
  <FormattedString>
   <Span Text="Click "/>
   <local:HyperlinkUI Text="here" LinkUrl="https://docs.microsoft.com/xamarin/"/>
   <Span Text=" to learn more about Syncfusion .NET MAUI Controls."/>
  </FormattedString>
 </Label.FormattedText>
</Label>

到此這篇關于.NET MAUI項目中創(chuàng)建超鏈接的文章就介紹到這了。希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

相關文章

最新評論

临高县| 沙河市| 天柱县| 渑池县| 敖汉旗| 鄂尔多斯市| 建始县| 南丰县| 库尔勒市| 南投市| 昌吉市| 大化| 应用必备| 博客| 襄垣县| 高陵县| 甘德县| 定南县| 南平市| 五大连池市| 海淀区| 平果县| 云林县| 永康市| 夹江县| 乌兰县| 铅山县| 吉安县| 大足县| 准格尔旗| 万年县| 福安市| 抚顺市| 连城县| 乌兰浩特市| 搜索| 宝山区| 丹阳市| 邓州市| 确山县| 桦川县|