shuhelohelo’s blog

Xamarin.Forms多めです.

Xamarin.FormsのGridのRow/Column Definitionをインラインで書けるようになる予定

blog.verslu.is

Xamarin.Forms 4.7 pre-1以降で使えるとのことなので使ってみた.

まずは現時点で最新のXamarin.Forms 4.7 pre-4をインストールする.

Nugetパッケージマネージャからインストール(アップデート)をする.

f:id:shuhelohelo:20200617224413p:plain

プレビュー版を検索候補に出す場合は,検索ボックスの右側にあるInclude prereleaseにチェックをつける必要がある.

これまで,以下のように書いていたものが

    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="1*"/>
            <ColumnDefinition Width="2*"/>
            <ColumnDefinition Width="auto"/>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="100"/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="1*"/>
            <RowDefinition Height="auto"/>
            <RowDefinition Height="2*"/>
            <RowDefinition Height="100"/>
            <RowDefinition Height="3*"/>
        </Grid.RowDefinitions>
...
    </Grid>

以下のように簡潔に書くことができるようになる.

    <Grid ColumnDefinitions="1*,2*,auto,*,100" RowDefinitions="1*,auto,2*,100,3*">
...
    </Grid>

素晴らしい!

ソースコード

github.com