Xamarin List View Item Text in horizontal and vertical middle not working











up vote
0
down vote

favorite












So I have a ListView and I cant get the Text to be in both horizontal and vertical middle.



I tried this:



                    <ListView x:Name="EssenListView" 
ItemsSource="{Binding EssenAnTag}"
Footer=""
SeparatorVisibility="None"
VerticalOptions="FillAndExpand"
HorizontalOptions="FillAndExpand"
HasUnevenRows="true"
RefreshCommand="{Binding EssenLadenCommand}"
IsPullToRefreshEnabled="true"
IsRefreshing="{Binding Laedt, Mode=OneWay}"
ItemSelected="EssenGewaehlt">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<ViewCell.View>
<StackLayout>
<StackLayout HorizontalOptions="FillAndExpand" HeightRequest="65" BackgroundColor="{Binding BackgroundColor}">
<Label Text="{Binding Ausgabe}"
FontSize="18"
HorizontalOptions="Center"
VerticalOptions="Center"
LineBreakMode="WordWrap" />
</StackLayout>
<Label HeightRequest="15" BackgroundColor="White"/>
</StackLayout>
</ViewCell.View>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>


As you can see in the image below if the text is small its at least horizontal centered but if the text is long and breaks its not centered at all.enter image description here










share|improve this question


























    up vote
    0
    down vote

    favorite












    So I have a ListView and I cant get the Text to be in both horizontal and vertical middle.



    I tried this:



                        <ListView x:Name="EssenListView" 
    ItemsSource="{Binding EssenAnTag}"
    Footer=""
    SeparatorVisibility="None"
    VerticalOptions="FillAndExpand"
    HorizontalOptions="FillAndExpand"
    HasUnevenRows="true"
    RefreshCommand="{Binding EssenLadenCommand}"
    IsPullToRefreshEnabled="true"
    IsRefreshing="{Binding Laedt, Mode=OneWay}"
    ItemSelected="EssenGewaehlt">
    <ListView.ItemTemplate>
    <DataTemplate>
    <ViewCell>
    <ViewCell.View>
    <StackLayout>
    <StackLayout HorizontalOptions="FillAndExpand" HeightRequest="65" BackgroundColor="{Binding BackgroundColor}">
    <Label Text="{Binding Ausgabe}"
    FontSize="18"
    HorizontalOptions="Center"
    VerticalOptions="Center"
    LineBreakMode="WordWrap" />
    </StackLayout>
    <Label HeightRequest="15" BackgroundColor="White"/>
    </StackLayout>
    </ViewCell.View>
    </ViewCell>
    </DataTemplate>
    </ListView.ItemTemplate>
    </ListView>


    As you can see in the image below if the text is small its at least horizontal centered but if the text is long and breaks its not centered at all.enter image description here










    share|improve this question
























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      So I have a ListView and I cant get the Text to be in both horizontal and vertical middle.



      I tried this:



                          <ListView x:Name="EssenListView" 
      ItemsSource="{Binding EssenAnTag}"
      Footer=""
      SeparatorVisibility="None"
      VerticalOptions="FillAndExpand"
      HorizontalOptions="FillAndExpand"
      HasUnevenRows="true"
      RefreshCommand="{Binding EssenLadenCommand}"
      IsPullToRefreshEnabled="true"
      IsRefreshing="{Binding Laedt, Mode=OneWay}"
      ItemSelected="EssenGewaehlt">
      <ListView.ItemTemplate>
      <DataTemplate>
      <ViewCell>
      <ViewCell.View>
      <StackLayout>
      <StackLayout HorizontalOptions="FillAndExpand" HeightRequest="65" BackgroundColor="{Binding BackgroundColor}">
      <Label Text="{Binding Ausgabe}"
      FontSize="18"
      HorizontalOptions="Center"
      VerticalOptions="Center"
      LineBreakMode="WordWrap" />
      </StackLayout>
      <Label HeightRequest="15" BackgroundColor="White"/>
      </StackLayout>
      </ViewCell.View>
      </ViewCell>
      </DataTemplate>
      </ListView.ItemTemplate>
      </ListView>


      As you can see in the image below if the text is small its at least horizontal centered but if the text is long and breaks its not centered at all.enter image description here










      share|improve this question













      So I have a ListView and I cant get the Text to be in both horizontal and vertical middle.



      I tried this:



                          <ListView x:Name="EssenListView" 
      ItemsSource="{Binding EssenAnTag}"
      Footer=""
      SeparatorVisibility="None"
      VerticalOptions="FillAndExpand"
      HorizontalOptions="FillAndExpand"
      HasUnevenRows="true"
      RefreshCommand="{Binding EssenLadenCommand}"
      IsPullToRefreshEnabled="true"
      IsRefreshing="{Binding Laedt, Mode=OneWay}"
      ItemSelected="EssenGewaehlt">
      <ListView.ItemTemplate>
      <DataTemplate>
      <ViewCell>
      <ViewCell.View>
      <StackLayout>
      <StackLayout HorizontalOptions="FillAndExpand" HeightRequest="65" BackgroundColor="{Binding BackgroundColor}">
      <Label Text="{Binding Ausgabe}"
      FontSize="18"
      HorizontalOptions="Center"
      VerticalOptions="Center"
      LineBreakMode="WordWrap" />
      </StackLayout>
      <Label HeightRequest="15" BackgroundColor="White"/>
      </StackLayout>
      </ViewCell.View>
      </ViewCell>
      </DataTemplate>
      </ListView.ItemTemplate>
      </ListView>


      As you can see in the image below if the text is small its at least horizontal centered but if the text is long and breaks its not centered at all.enter image description here







      listview xamarin.forms centering






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 2 days ago









      Kai

      396




      396
























          2 Answers
          2






          active

          oldest

          votes

















          up vote
          0
          down vote













          Adding HorizontalTextAlignment="Center" property in your Label control, like this:



                                            <Label Text="{Binding Ausgabe}" 
          FontSize="18"
          HorizontalOptions="Center"
          HorizontalTextAlignment="Center"
          VerticalOptions="Center"
          LineBreakMode="WordWrap" />





          share|improve this answer




























            up vote
            0
            down vote













            Use HorizontalTextAlignment="Center" to align text in Label.



            HorizontalOptions="Center" align the Label itself.






            share|improve this answer










            New contributor




            Ataberk Uzkal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.


















              Your Answer






              StackExchange.ifUsing("editor", function () {
              StackExchange.using("externalEditor", function () {
              StackExchange.using("snippets", function () {
              StackExchange.snippets.init();
              });
              });
              }, "code-snippets");

              StackExchange.ready(function() {
              var channelOptions = {
              tags: "".split(" "),
              id: "1"
              };
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function() {
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled) {
              StackExchange.using("snippets", function() {
              createEditor();
              });
              }
              else {
              createEditor();
              }
              });

              function createEditor() {
              StackExchange.prepareEditor({
              heartbeatType: 'answer',
              convertImagesToLinks: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              imageUploader: {
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              },
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              });


              }
              });














               

              draft saved


              draft discarded


















              StackExchange.ready(
              function () {
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53204245%2fxamarin-list-view-item-text-in-horizontal-and-vertical-middle-not-working%23new-answer', 'question_page');
              }
              );

              Post as a guest
































              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes








              up vote
              0
              down vote













              Adding HorizontalTextAlignment="Center" property in your Label control, like this:



                                                <Label Text="{Binding Ausgabe}" 
              FontSize="18"
              HorizontalOptions="Center"
              HorizontalTextAlignment="Center"
              VerticalOptions="Center"
              LineBreakMode="WordWrap" />





              share|improve this answer

























                up vote
                0
                down vote













                Adding HorizontalTextAlignment="Center" property in your Label control, like this:



                                                  <Label Text="{Binding Ausgabe}" 
                FontSize="18"
                HorizontalOptions="Center"
                HorizontalTextAlignment="Center"
                VerticalOptions="Center"
                LineBreakMode="WordWrap" />





                share|improve this answer























                  up vote
                  0
                  down vote










                  up vote
                  0
                  down vote









                  Adding HorizontalTextAlignment="Center" property in your Label control, like this:



                                                    <Label Text="{Binding Ausgabe}" 
                  FontSize="18"
                  HorizontalOptions="Center"
                  HorizontalTextAlignment="Center"
                  VerticalOptions="Center"
                  LineBreakMode="WordWrap" />





                  share|improve this answer












                  Adding HorizontalTextAlignment="Center" property in your Label control, like this:



                                                    <Label Text="{Binding Ausgabe}" 
                  FontSize="18"
                  HorizontalOptions="Center"
                  HorizontalTextAlignment="Center"
                  VerticalOptions="Center"
                  LineBreakMode="WordWrap" />






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered yesterday









                  Cherry Bu

                  82328




                  82328
























                      up vote
                      0
                      down vote













                      Use HorizontalTextAlignment="Center" to align text in Label.



                      HorizontalOptions="Center" align the Label itself.






                      share|improve this answer










                      New contributor




                      Ataberk Uzkal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                      Check out our Code of Conduct.






















                        up vote
                        0
                        down vote













                        Use HorizontalTextAlignment="Center" to align text in Label.



                        HorizontalOptions="Center" align the Label itself.






                        share|improve this answer










                        New contributor




                        Ataberk Uzkal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                        Check out our Code of Conduct.




















                          up vote
                          0
                          down vote










                          up vote
                          0
                          down vote









                          Use HorizontalTextAlignment="Center" to align text in Label.



                          HorizontalOptions="Center" align the Label itself.






                          share|improve this answer










                          New contributor




                          Ataberk Uzkal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.









                          Use HorizontalTextAlignment="Center" to align text in Label.



                          HorizontalOptions="Center" align the Label itself.







                          share|improve this answer










                          New contributor




                          Ataberk Uzkal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.









                          share|improve this answer



                          share|improve this answer








                          edited yesterday





















                          New contributor




                          Ataberk Uzkal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.









                          answered yesterday









                          Ataberk Uzkal

                          13




                          13




                          New contributor




                          Ataberk Uzkal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.





                          New contributor





                          Ataberk Uzkal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.






                          Ataberk Uzkal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.






























                               

                              draft saved


                              draft discarded



















































                               


                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function () {
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53204245%2fxamarin-list-view-item-text-in-horizontal-and-vertical-middle-not-working%23new-answer', 'question_page');
                              }
                              );

                              Post as a guest




















































































                              Popular posts from this blog

                              How to pass form data using jquery Ajax to insert data in database?

                              National Museum of Racing and Hall of Fame

                              Guess what letter conforming each word