常用代碼(待更新)

Model

public class Model : INotifyPropertyChanged
{
    private string content;
    public string Content {

        get
        {
            return content;
        }
        set {
            content = value;
            NotifyPropertyChanged();
        }
    }

    public event PropertyChangedEventHandler PropertyChanged;

    private void NotifyPropertyChanged([CallerMemberName] String propertyName = "")
    {
        PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
    }
}

Custom Renderer

[assembly: ExportRenderer(typeof(TableView), typeof(CustomListRenderer))]
namespace PPPPCL.iOS
{
    class CustomListRenderer  :TableViewRenderer
    {
       protected override void OnElementChanged(ElementChangedEventArgs<TableView> e)
        {
            base.OnElementChanged(e);
            if(Control != null)
            {
            
            }
        }
    }
}

BindableStackLayout

public class BindableStackLayout : StackLayout
{
    public IEnumerable ItemsSource
    {
        get { return (IEnumerable)GetValue(ItemsSourceProperty); }
        set { SetValue(ItemsSourceProperty, value); }
    }
    public static readonly BindableProperty ItemsSourceProperty =
        BindableProperty.Create(nameof(ItemsSource), typeof(IEnumerable), typeof(BindableStackLayout),
                                propertyChanged: (bindable, oldValue, newValue) => ((BindableStackLayout)bindable).PopulateItems());

    public DataTemplate ItemDataTemplate
    {
        get { return (DataTemplate)GetValue(ItemDataTemplateProperty); }
        set { SetValue(ItemDataTemplateProperty, value); }
    }
    public static readonly BindableProperty ItemDataTemplateProperty =
        BindableProperty.Create(nameof(ItemDataTemplate), typeof(DataTemplate), typeof(BindableStackLayout));

    void PopulateItems()
    {
        if (ItemsSource == null) return;
        foreach (var item in ItemsSource)
        {
            var itemTemplate = ItemDataTemplate.CreateContent() as Xamarin.Forms.View;
            itemTemplate.BindingContext = item;
            Children.Add(itemTemplate);
        }
    }
}

查看已有的fontName

foreach (var familyNames in UIFont.FamilyNames.OrderBy(c => c).ToList())
        {
            Console.WriteLine(" * " + familyNames);
            foreach (var familyName in UIFont.FontNamesForFamilyName(familyNames).OrderBy(c => c).ToList())
            {
                Console.WriteLine(" *-- " + familyName);
            }
        }

OnPlatform 用法

代碼

 Icon = (Device.RuntimePlatform == Device.iOS) ? "tab_about.png" : null;

xaml

         <ContentPage.Padding>
    <OnPlatform x:TypeArguments="Thickness">
        <OnPlatform.Platforms>
            <On Platform="iOS" Value="0, 20, 0, 0" />
            <On Platform="Android" Value="0, 0, 0, 0" />
            <On Platform="UWP" Value="0, 0, 0, 0" />
        </OnPlatform.Platforms>
    </OnPlatform>
   </ContentPage.Padding>
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市,隨后出現(xiàn)的幾起案子腊敲,更是在濱河造成了極大的恐慌,老刑警劉巖算墨,帶你破解...
    沈念sama閱讀 218,284評論 6 506
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異汁雷,居然都是意外死亡净嘀,警方通過查閱死者的電腦和手機,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,115評論 3 395
  • 文/潘曉璐 我一進店門摔竿,熙熙樓的掌柜王于貴愁眉苦臉地迎上來面粮,“玉大人少孝,你說我怎么就攤上這事继低。” “怎么了稍走?”我有些...
    開封第一講書人閱讀 164,614評論 0 354
  • 文/不壞的土叔 我叫張陵袁翁,是天一觀的道長柴底。 經(jīng)常有香客問我,道長粱胜,這世上最難降的妖魔是什么柄驻? 我笑而不...
    開封第一講書人閱讀 58,671評論 1 293
  • 正文 為了忘掉前任,我火速辦了婚禮焙压,結(jié)果婚禮上鸿脓,老公的妹妹穿的比我還像新娘。我一直安慰自己涯曲,他們只是感情好野哭,可當(dāng)我...
    茶點故事閱讀 67,699評論 6 392
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著幻件,像睡著了一般拨黔。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上绰沥,一...
    開封第一講書人閱讀 51,562評論 1 305
  • 那天篱蝇,我揣著相機與錄音,去河邊找鬼徽曲。 笑死零截,一個胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的疟位。 我是一名探鬼主播瞻润,決...
    沈念sama閱讀 40,309評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼甜刻!你這毒婦竟也來了绍撞?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 39,223評論 0 276
  • 序言:老撾萬榮一對情侶失蹤得院,失蹤者是張志新(化名)和其女友劉穎傻铣,沒想到半個月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體祥绞,經(jīng)...
    沈念sama閱讀 45,668評論 1 314
  • 正文 獨居荒郊野嶺守林人離奇死亡非洲,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 37,859評論 3 336
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發(fā)現(xiàn)自己被綠了蜕径。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片两踏。...
    茶點故事閱讀 39,981評論 1 348
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖兜喻,靈堂內(nèi)的尸體忽然破棺而出梦染,到底是詐尸還是另有隱情,我是刑警寧澤,帶...
    沈念sama閱讀 35,705評論 5 347
  • 正文 年R本政府宣布帕识,位于F島的核電站泛粹,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏肮疗。R本人自食惡果不足惜晶姊,卻給世界環(huán)境...
    茶點故事閱讀 41,310評論 3 330
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望伪货。 院中可真熱鬧们衙,春花似錦、人聲如沸碱呼。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,904評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽巍举。三九已至脆荷,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間懊悯,已是汗流浹背蜓谋。 一陣腳步聲響...
    開封第一講書人閱讀 33,023評論 1 270
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留炭分,地道東北人桃焕。 一個月前我還...
    沈念sama閱讀 48,146評論 3 370
  • 正文 我出身青樓,卻偏偏與公主長得像捧毛,于是被迫代替她去往敵國和親观堂。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點故事閱讀 44,933評論 2 355

推薦閱讀更多精彩內(nèi)容