成人午夜视频全免费观看高清-秋霞福利视频一区二区三区-国产精品久久久久电影小说-亚洲不卡区三一区三区一区

XamarinXAML語言中如何實現(xiàn)模板視圖TemplatedView

這篇文章給大家分享的是有關Xamarin XAML語言中如何實現(xiàn)模板視圖TemplatedView的內(nèi)容。小編覺得挺實用的,因此分享給大家做個參考,一起跟隨小編過來看看吧。

讓客戶滿意是我們工作的目標,不斷超越客戶的期望值來自于我們對這個行業(yè)的熱愛。我們立志把好的技術通過有效、簡單的方式提供給客戶,將通過不懈努力成為客戶在信息化領域值得信任、有價值的長期合作伙伴,公司提供的服務項目有:域名與空間、網(wǎng)站空間、營銷軟件、網(wǎng)站建設、柞水網(wǎng)站維護、網(wǎng)站推廣。

模板視圖TemplatedView

與模板頁面相對的是TemplatedView,它被稱為模板視圖,它的功能和模板頁面類似,也是用來顯示控件模板的,只不過比模板頁面更加靈活。TemplatedView提供ControlTemplate屬性,實現(xiàn)對控件模板的關聯(lián),從而展現(xiàn)對應的界面。

【示例14-6:TemplatedViewDemo】以下將使用模板視圖顯示控件模板,并實現(xiàn)模板的切換。具體的操作步驟如下:

(1)打開App.xaml文件,編寫代碼,實現(xiàn)在應用程序級別中構建控件模板,代碼如下:

  • <?xml version="1.0" encoding="utf-8" ?>

  • <Application xmlns="http://xamarin.com/schemas/2014/forms"

  •              xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"

  •              x:Class="TemplatedViewDemo.App">

  •   <Application.Resources>

  • <ResourceDictionary>

  • <!--構建控件模板-->

  •       <ControlTemplate x:Key="ChineseTemplate">

  •         <StackLayout>

  •           <StackLayout VerticalOptions="End">

  •             <BoxView Color="Aqua" />

  •           </StackLayout>

  •           <StackLayout Spacing="35"

  •             VerticalOptions="CenterAndExpand"  >

  •             <Frame OutlineColor="Accent">

  •               <StackLayout Spacing="20"

  •                            VerticalOptions="CenterAndExpand"

  •                            HorizontalOptions="Center">

  •                 <Label Text="山居秋暝"

  •                        FontSize="30"

  •                        FontAttributes="Bold"

  •                        HorizontalOptions="Center"/>

  •                 <Label Text="空山新雨后,天氣晚來秋。"

  •                        FontSize="18"/>

  •                 <Label Text="明月松間照,清泉石上流。"

  •                        FontSize="18"/>

  •                 <Label Text="竹喧歸浣女,蓮動下漁舟。"

  •                        FontSize="18"/>

  •                 <Label Text="隨意春芳歇,王孫自可留。"

  •                        FontSize="18"/>

  •               </StackLayout>

  •             </Frame>

  •             <Button Command="{TemplateBinding Parent. CommandEnglish}"

  •                       Text="Enter English Template" />

  •           </StackLayout>

  •         </StackLayout>

  •       </ControlTemplate>

  • <!--構建控件模板-->

  •       <ControlTemplate x:Key="EnglishTemplate">

  •         <StackLayout>

  •           <StackLayout VerticalOptions="End">

  •             <BoxView Color="Green" />

  •           </StackLayout>

  •           <StackLayout Spacing="35"

  •                        VerticalOptions="CenterAndExpand"  >

  •             <Frame OutlineColor="Accent">

  •               <Label Text="your life only lasts for a few decades, so be sure that you don\'t leave any regrets. laugh or cry as you like, and it‘s meaningless to oppress yourself."

  •                      FontAttributes="Bold"

  •                      FontSize="18"/>

  •             </Frame>

  •             <Button Command="{TemplateBinding Parent.CommandChinese}"

  •                     Text="Enter Chinese Template" />

  •           </StackLayout>

  •         </StackLayout>

  •       </ControlTemplate>

  •     </ResourceDictionary>

  •   </Application.Resources>

  • </Application>

在此代碼中,我們構建了兩個控件模板,一個為ChineseTemplate控件模板,另一為EnglishTemplate控件模板。

感謝各位的閱讀!關于“Xamarin XAML語言中如何實現(xiàn)模板視圖TemplatedView”這篇文章就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,讓大家可以學到更多知識,如果覺得文章不錯,可以把它分享出去讓更多的人看到吧!

本文名稱:XamarinXAML語言中如何實現(xiàn)模板視圖TemplatedView
文章位置:http://jinyejixie.com/article16/ijdggg.html

成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供動態(tài)網(wǎng)站、做網(wǎng)站、品牌網(wǎng)站制作、靜態(tài)網(wǎng)站ChatGPT、網(wǎng)頁設計公司

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉載內(nèi)容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)

成都網(wǎng)站建設
海南省| 常熟市| 三明市| 丰城市| 瑞丽市| 军事| 外汇| 县级市| 炉霍县| 从江县| 巴林左旗| 房山区| 峡江县| 石林| 从江县| 巴林左旗| 曲水县| 迁安市| 海阳市| 白玉县| 库车县| 平凉市| 酉阳| 唐海县| 永年县| 舒兰市| 瓦房店市| 荣成市| 彭泽县| 常熟市| 道真| 略阳县| 陆良县| 宁陵县| 永泰县| 交口县| 乐亭县| 辰溪县| 延寿县| 壤塘县| 滕州市|