2014-06-08 17 views
8

mi piacerebbe utilizzare un espansioneEntry e Button in orizzontale StackLayout:voce non adotta LayoutOptions.StartAndExpand nel contesto orizzontale

var item = new StackLayout { 
    Orientation = StackOrientation.Horizontal, 
    HorizontalOptions = LayoutOptions.FillAndExpand, 
    Children = { 

     new Entry { 
      Placeholder = "Feldtitel", 
      VerticalOptions = LayoutOptions.Center, 
      HorizontalOptions = LayoutOptions.StartAndExpand // NOTE THIS 
     }, 
     new Button{ 
      Text = CFieldDescription.getNameForFieldType(fieldType), 
      VerticalOptions = LayoutOptions.Center, 
      HorizontalOptions = LayoutOptions.End 
     } 

    }}; 

Mentre il Entry è in partenza, il Button è alla fine, Xamarin.Formsnon cambia la dimensione di Entry per riempire lo spazio orizzontale:

enter image description here

Devo modificare il mio codice? O ho trovato un bug?

risposta

16

Modificare il Entry.HorizontalOptions-LayoutOptions.FillAndExpand per ottenere l'effetto desiderato:

var item = new StackLayout { 
    Orientation = StackOrientation.Horizontal, 
    HorizontalOptions = LayoutOptions.FillAndExpand, 
    Spacing = 12, //you probably want this 
    Children = { 
     new Entry { 
      Placeholder = "Feldtitel", 
      VerticalOptions = LayoutOptions.Center, 
      HorizontalOptions = LayoutOptions.FillAndExpand //there, fixed 
     }, 
     new Button{ 
      Text = CFieldDescription.getNameForFieldType(fieldType), 
      VerticalOptions = LayoutOptions.Center, 
      HorizontalOptions = LayoutOptions.End 
     } 
    }}; 

Sembra che il LayoutOptions bisogno di qualche buona documentazione.

+0

'Pulsante' ha lo stesso problema. Ma dopo averlo cambiato in "FillAndExpand', anche" Button.Text "viene visualizzato solo a metà, non da sinistra. C'è un modo per risolvere anche questo? Grazie. – qakmak

Problemi correlati