2017-04-05 9 views
1

ボタンを組み合わせたテキストラベルやテキストの一部の色が異なる場合があります。 「サインイン」テキストボタンは、それに接続作用を有し、また、テキストの残りの部分は異なる表情を持つ必要が enter image description hereXamarinフォームのリンクボタンとテキストの位置合わせ

この時、私はこれを達成する必要があります。

私はHorizo​​ntal属性でStackViewを試しましたが、デバイスの幅とテキストの長さにあまり依存せず、画面上で水平に中央に見えません。 HTML形式で

私は

Already have an account? <a>Sign in</a> 

ような何かをするだろうXAMLのようなものはありますか?

答えて

1

グリッドはボタンが使用されていないとして、iOSとAndroidの上で一貫性のある外観を生み出す一つのアプローチです。背後にあるコードでは

<Grid Padding="20"> 
    <Grid.RowDefinitions> 
     <RowDefinition Height="40" /> 
    </Grid.RowDefinitions> 
    <Grid.ColumnDefinitions> 
     <ColumnDefinition Width="Auto" /> 
     <ColumnDefinition Width="Auto" /> 
    </Grid.ColumnDefinitions> 
    <Label Grid.Row="0" Grid.Column="0" Text="Already have an account?" TextColor="Black" BackgroundColor="White" /> 
    <Label x:Name="onSignIn" Grid.Row="0" Grid.Column="1" Text="Sign In" TextColor="Red" BackgroundColor="White" /> 
</Grid> 

enter image description here

var tapGestureRecognizer = new TapGestureRecognizer(); 
tapGestureRecognizer.Tapped += (sender, e) => D.WriteLine("Tapped"); 
onSignIn.GestureRecognizers.Add(tapGestureRecognizer); 
1

はい - スパン。あなたは

はあなたのビューモデルにFormattedStringを構築していることをバインドすることができますので、スパンテキストはバインド可能ではありませんが、レーベルFormattedTextがある

<Label> 
    <Label.FormattedText> 
     <FormattedString> 
      <FormattedString.Spans> 
       <Span Text="Hello" ForegroundColor="Red" FontAttributes="Italic" FontSize="10" /> 
       <Span Text="World" ForegroundColor="Blue" FontSize="10" /> 
      </FormattedString.Spans> 
     </FormattedString> 
    </Label.FormattedText> 
</Label> 
異なるフォントを持っているスパン、色、サイズなどを使用してフォーマットされた文字列を構築することができますFormattedTextプロパティに追加します。 Sign Inラベルの自動サイズの列と TapGestureRecognizer

関連する問題