UWP AdaptiveGrivew horizontalAligment not working










0















I creat app UWP and using AdaptiveGridView of Mircosoft.Toolkit but when i create my ToggleButton in AdaptiveGridView not in center. How i can fix it?



This is problem



My Code



<Page.Resources>
<DataTemplate x:Key="ToggleButtonTemplate">
<Grid>
<ToggleButton x:Name="a" Content="Binding Textttt"
HorizontalAlignment="Center"
VerticalAlignment="Center"
MinWidth="150" Click="Button_Click"
Style="StaticResource HeinekenToggleButtonStyle"
/>
</Grid>
</DataTemplate>
<Page.Resources>
<controls:AdaptiveGridView Name="MenuItemGrid"
HorizontalAlignment="Center"
VerticalAlignment="Top"
Margin="5"
ItemTemplate="StaticResource ToggleButtonTemplate"
Grid.Row="0"/>









share|improve this question




























    0















    I creat app UWP and using AdaptiveGridView of Mircosoft.Toolkit but when i create my ToggleButton in AdaptiveGridView not in center. How i can fix it?



    This is problem



    My Code



    <Page.Resources>
    <DataTemplate x:Key="ToggleButtonTemplate">
    <Grid>
    <ToggleButton x:Name="a" Content="Binding Textttt"
    HorizontalAlignment="Center"
    VerticalAlignment="Center"
    MinWidth="150" Click="Button_Click"
    Style="StaticResource HeinekenToggleButtonStyle"
    />
    </Grid>
    </DataTemplate>
    <Page.Resources>
    <controls:AdaptiveGridView Name="MenuItemGrid"
    HorizontalAlignment="Center"
    VerticalAlignment="Top"
    Margin="5"
    ItemTemplate="StaticResource ToggleButtonTemplate"
    Grid.Row="0"/>









    share|improve this question


























      0












      0








      0








      I creat app UWP and using AdaptiveGridView of Mircosoft.Toolkit but when i create my ToggleButton in AdaptiveGridView not in center. How i can fix it?



      This is problem



      My Code



      <Page.Resources>
      <DataTemplate x:Key="ToggleButtonTemplate">
      <Grid>
      <ToggleButton x:Name="a" Content="Binding Textttt"
      HorizontalAlignment="Center"
      VerticalAlignment="Center"
      MinWidth="150" Click="Button_Click"
      Style="StaticResource HeinekenToggleButtonStyle"
      />
      </Grid>
      </DataTemplate>
      <Page.Resources>
      <controls:AdaptiveGridView Name="MenuItemGrid"
      HorizontalAlignment="Center"
      VerticalAlignment="Top"
      Margin="5"
      ItemTemplate="StaticResource ToggleButtonTemplate"
      Grid.Row="0"/>









      share|improve this question
















      I creat app UWP and using AdaptiveGridView of Mircosoft.Toolkit but when i create my ToggleButton in AdaptiveGridView not in center. How i can fix it?



      This is problem



      My Code



      <Page.Resources>
      <DataTemplate x:Key="ToggleButtonTemplate">
      <Grid>
      <ToggleButton x:Name="a" Content="Binding Textttt"
      HorizontalAlignment="Center"
      VerticalAlignment="Center"
      MinWidth="150" Click="Button_Click"
      Style="StaticResource HeinekenToggleButtonStyle"
      />
      </Grid>
      </DataTemplate>
      <Page.Resources>
      <controls:AdaptiveGridView Name="MenuItemGrid"
      HorizontalAlignment="Center"
      VerticalAlignment="Top"
      Margin="5"
      ItemTemplate="StaticResource ToggleButtonTemplate"
      Grid.Row="0"/>






      .net xaml uwp






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 20 '18 at 8:10









      Nico Zhu - MSFT

      9,5881421




      9,5881421










      asked Nov 14 '18 at 7:07









      Mr DMr D

      53




      53






















          2 Answers
          2






          active

          oldest

          votes


















          0














          Try to use Row and Column definitions and then set Grid.Column="0" and Grid.Row="0" for ToggleButton like this:



           <Grid>
          <Grid.RowDefinitions>
          <RowDefinition Height="*"/><RowDefinition/>
          </Grid.RowDefinitions>
          <Grid.ColumnDefinitions>
          <ColumnDefinition Width="*"/><ColumnDefinition/>
          </Grid.ColumnDefinitions>

          <ToggleButton x:Name="a" Grid.Row="0" Grid.Column="0" Content="Binding Textttt"
          HorizontalAlignment="Center" VerticalAlignment="Center"
          MinWidth="150" Click="Button_Click" Style="StaticResource HeinekenToggleButtonStyle"
          />
          </Grid>


          I hope this help you.






          share|improve this answer























          • It's not working. I just want item in adaptiveGridvew horizontal center. But horizontal not working, i don't understand.

            – Mr D
            Nov 14 '18 at 9:33












          • I think ToggleButtons are centered in its parent Grid But for AdaptiveGridView , Which version of toolkit is installed? refer to this old fix for this problem AdaptiveGridView HorizontalAlignment not working after version 2.0.0 Also did you tested it by replacing AdaptiveGridView with standard GridView ?

            – MKH
            Nov 14 '18 at 9:55












          • i use version 5.0.0. I have read your link but i don't understand and i don't see how to fix it

            – Mr D
            Nov 14 '18 at 10:04











          • I have a try with GridView but it does not work either

            – Mr D
            Nov 14 '18 at 10:10











          • If you are using ver5.0 no problem , Its an old thread and fixed already.

            – MKH
            Nov 14 '18 at 10:12



















          0














          This works as expected. At first I thought what is wrong at all looking at the picture. At the end I realize that you want the last two items to be centered in the last row instead of displaying them from the start.



          In theory it is possible, but there is no operating system in existence with controls that would work like that as far as I know (and I've built applications for all major operating systems). So you have to build everything from the scratch if you really want that, you can't rely on any control as simply this isn't considered as a good design.



          Horizontal alignment means of how your control is placed inside its container, not how the container is placed inside its row, there is no property that would affect that.






          share|improve this answer






















            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',
            autoActivateHeartbeat: false,
            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%2f53294775%2fuwp-adaptivegrivew-horizontalaligment-not-working%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            Try to use Row and Column definitions and then set Grid.Column="0" and Grid.Row="0" for ToggleButton like this:



             <Grid>
            <Grid.RowDefinitions>
            <RowDefinition Height="*"/><RowDefinition/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"/><ColumnDefinition/>
            </Grid.ColumnDefinitions>

            <ToggleButton x:Name="a" Grid.Row="0" Grid.Column="0" Content="Binding Textttt"
            HorizontalAlignment="Center" VerticalAlignment="Center"
            MinWidth="150" Click="Button_Click" Style="StaticResource HeinekenToggleButtonStyle"
            />
            </Grid>


            I hope this help you.






            share|improve this answer























            • It's not working. I just want item in adaptiveGridvew horizontal center. But horizontal not working, i don't understand.

              – Mr D
              Nov 14 '18 at 9:33












            • I think ToggleButtons are centered in its parent Grid But for AdaptiveGridView , Which version of toolkit is installed? refer to this old fix for this problem AdaptiveGridView HorizontalAlignment not working after version 2.0.0 Also did you tested it by replacing AdaptiveGridView with standard GridView ?

              – MKH
              Nov 14 '18 at 9:55












            • i use version 5.0.0. I have read your link but i don't understand and i don't see how to fix it

              – Mr D
              Nov 14 '18 at 10:04











            • I have a try with GridView but it does not work either

              – Mr D
              Nov 14 '18 at 10:10











            • If you are using ver5.0 no problem , Its an old thread and fixed already.

              – MKH
              Nov 14 '18 at 10:12
















            0














            Try to use Row and Column definitions and then set Grid.Column="0" and Grid.Row="0" for ToggleButton like this:



             <Grid>
            <Grid.RowDefinitions>
            <RowDefinition Height="*"/><RowDefinition/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"/><ColumnDefinition/>
            </Grid.ColumnDefinitions>

            <ToggleButton x:Name="a" Grid.Row="0" Grid.Column="0" Content="Binding Textttt"
            HorizontalAlignment="Center" VerticalAlignment="Center"
            MinWidth="150" Click="Button_Click" Style="StaticResource HeinekenToggleButtonStyle"
            />
            </Grid>


            I hope this help you.






            share|improve this answer























            • It's not working. I just want item in adaptiveGridvew horizontal center. But horizontal not working, i don't understand.

              – Mr D
              Nov 14 '18 at 9:33












            • I think ToggleButtons are centered in its parent Grid But for AdaptiveGridView , Which version of toolkit is installed? refer to this old fix for this problem AdaptiveGridView HorizontalAlignment not working after version 2.0.0 Also did you tested it by replacing AdaptiveGridView with standard GridView ?

              – MKH
              Nov 14 '18 at 9:55












            • i use version 5.0.0. I have read your link but i don't understand and i don't see how to fix it

              – Mr D
              Nov 14 '18 at 10:04











            • I have a try with GridView but it does not work either

              – Mr D
              Nov 14 '18 at 10:10











            • If you are using ver5.0 no problem , Its an old thread and fixed already.

              – MKH
              Nov 14 '18 at 10:12














            0












            0








            0







            Try to use Row and Column definitions and then set Grid.Column="0" and Grid.Row="0" for ToggleButton like this:



             <Grid>
            <Grid.RowDefinitions>
            <RowDefinition Height="*"/><RowDefinition/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"/><ColumnDefinition/>
            </Grid.ColumnDefinitions>

            <ToggleButton x:Name="a" Grid.Row="0" Grid.Column="0" Content="Binding Textttt"
            HorizontalAlignment="Center" VerticalAlignment="Center"
            MinWidth="150" Click="Button_Click" Style="StaticResource HeinekenToggleButtonStyle"
            />
            </Grid>


            I hope this help you.






            share|improve this answer













            Try to use Row and Column definitions and then set Grid.Column="0" and Grid.Row="0" for ToggleButton like this:



             <Grid>
            <Grid.RowDefinitions>
            <RowDefinition Height="*"/><RowDefinition/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"/><ColumnDefinition/>
            </Grid.ColumnDefinitions>

            <ToggleButton x:Name="a" Grid.Row="0" Grid.Column="0" Content="Binding Textttt"
            HorizontalAlignment="Center" VerticalAlignment="Center"
            MinWidth="150" Click="Button_Click" Style="StaticResource HeinekenToggleButtonStyle"
            />
            </Grid>


            I hope this help you.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 14 '18 at 9:13









            MKHMKH

            232310




            232310












            • It's not working. I just want item in adaptiveGridvew horizontal center. But horizontal not working, i don't understand.

              – Mr D
              Nov 14 '18 at 9:33












            • I think ToggleButtons are centered in its parent Grid But for AdaptiveGridView , Which version of toolkit is installed? refer to this old fix for this problem AdaptiveGridView HorizontalAlignment not working after version 2.0.0 Also did you tested it by replacing AdaptiveGridView with standard GridView ?

              – MKH
              Nov 14 '18 at 9:55












            • i use version 5.0.0. I have read your link but i don't understand and i don't see how to fix it

              – Mr D
              Nov 14 '18 at 10:04











            • I have a try with GridView but it does not work either

              – Mr D
              Nov 14 '18 at 10:10











            • If you are using ver5.0 no problem , Its an old thread and fixed already.

              – MKH
              Nov 14 '18 at 10:12


















            • It's not working. I just want item in adaptiveGridvew horizontal center. But horizontal not working, i don't understand.

              – Mr D
              Nov 14 '18 at 9:33












            • I think ToggleButtons are centered in its parent Grid But for AdaptiveGridView , Which version of toolkit is installed? refer to this old fix for this problem AdaptiveGridView HorizontalAlignment not working after version 2.0.0 Also did you tested it by replacing AdaptiveGridView with standard GridView ?

              – MKH
              Nov 14 '18 at 9:55












            • i use version 5.0.0. I have read your link but i don't understand and i don't see how to fix it

              – Mr D
              Nov 14 '18 at 10:04











            • I have a try with GridView but it does not work either

              – Mr D
              Nov 14 '18 at 10:10











            • If you are using ver5.0 no problem , Its an old thread and fixed already.

              – MKH
              Nov 14 '18 at 10:12

















            It's not working. I just want item in adaptiveGridvew horizontal center. But horizontal not working, i don't understand.

            – Mr D
            Nov 14 '18 at 9:33






            It's not working. I just want item in adaptiveGridvew horizontal center. But horizontal not working, i don't understand.

            – Mr D
            Nov 14 '18 at 9:33














            I think ToggleButtons are centered in its parent Grid But for AdaptiveGridView , Which version of toolkit is installed? refer to this old fix for this problem AdaptiveGridView HorizontalAlignment not working after version 2.0.0 Also did you tested it by replacing AdaptiveGridView with standard GridView ?

            – MKH
            Nov 14 '18 at 9:55






            I think ToggleButtons are centered in its parent Grid But for AdaptiveGridView , Which version of toolkit is installed? refer to this old fix for this problem AdaptiveGridView HorizontalAlignment not working after version 2.0.0 Also did you tested it by replacing AdaptiveGridView with standard GridView ?

            – MKH
            Nov 14 '18 at 9:55














            i use version 5.0.0. I have read your link but i don't understand and i don't see how to fix it

            – Mr D
            Nov 14 '18 at 10:04





            i use version 5.0.0. I have read your link but i don't understand and i don't see how to fix it

            – Mr D
            Nov 14 '18 at 10:04













            I have a try with GridView but it does not work either

            – Mr D
            Nov 14 '18 at 10:10





            I have a try with GridView but it does not work either

            – Mr D
            Nov 14 '18 at 10:10













            If you are using ver5.0 no problem , Its an old thread and fixed already.

            – MKH
            Nov 14 '18 at 10:12






            If you are using ver5.0 no problem , Its an old thread and fixed already.

            – MKH
            Nov 14 '18 at 10:12














            0














            This works as expected. At first I thought what is wrong at all looking at the picture. At the end I realize that you want the last two items to be centered in the last row instead of displaying them from the start.



            In theory it is possible, but there is no operating system in existence with controls that would work like that as far as I know (and I've built applications for all major operating systems). So you have to build everything from the scratch if you really want that, you can't rely on any control as simply this isn't considered as a good design.



            Horizontal alignment means of how your control is placed inside its container, not how the container is placed inside its row, there is no property that would affect that.






            share|improve this answer



























              0














              This works as expected. At first I thought what is wrong at all looking at the picture. At the end I realize that you want the last two items to be centered in the last row instead of displaying them from the start.



              In theory it is possible, but there is no operating system in existence with controls that would work like that as far as I know (and I've built applications for all major operating systems). So you have to build everything from the scratch if you really want that, you can't rely on any control as simply this isn't considered as a good design.



              Horizontal alignment means of how your control is placed inside its container, not how the container is placed inside its row, there is no property that would affect that.






              share|improve this answer

























                0












                0








                0







                This works as expected. At first I thought what is wrong at all looking at the picture. At the end I realize that you want the last two items to be centered in the last row instead of displaying them from the start.



                In theory it is possible, but there is no operating system in existence with controls that would work like that as far as I know (and I've built applications for all major operating systems). So you have to build everything from the scratch if you really want that, you can't rely on any control as simply this isn't considered as a good design.



                Horizontal alignment means of how your control is placed inside its container, not how the container is placed inside its row, there is no property that would affect that.






                share|improve this answer













                This works as expected. At first I thought what is wrong at all looking at the picture. At the end I realize that you want the last two items to be centered in the last row instead of displaying them from the start.



                In theory it is possible, but there is no operating system in existence with controls that would work like that as far as I know (and I've built applications for all major operating systems). So you have to build everything from the scratch if you really want that, you can't rely on any control as simply this isn't considered as a good design.



                Horizontal alignment means of how your control is placed inside its container, not how the container is placed inside its row, there is no property that would affect that.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 20 '18 at 10:32









                Ivan IčinIvan Ičin

                3,87342343




                3,87342343



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53294775%2fuwp-adaptivegrivew-horizontalaligment-not-working%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Top Tejano songwriter Luis Silva dead of heart attack at 64

                    政党

                    天津地下鉄3号線