Why is textbox is always geting focus when I click the blank area of the page?

Multi tool use
Multi tool use












2














enter image description here



As the gif shows, My textbox is at the top of the scrollviewer. But when I scroll down, and click the blank area, the textbox always get focused.



It's annoying.



How to remove the textbox's auto focused?



    <ScrollViewer Grid.Row="1" Padding="5" Style="{StaticResource ScrollViewerAppleStyle}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition MinHeight="100" MaxHeight="400"/>
<RowDefinition Height="60"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="60"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="60"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="60"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="60"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="60"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="60"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>

<TextBox Text="欢迎使用小冰科技最新研发的自然语言处理程序。" x:Name="textInput" x:Uid="textBox_Input" TabIndex="-1" BorderBrush="Gray" BorderThickness="1" TextWrapping="Wrap" AcceptsReturn="True" Style="{StaticResource TransparentBackgroundTextBoxStyle}" ScrollViewer.VerticalScrollBarVisibility="Auto"/>

Other controls.......

</Grid>
</ScrollViewer>









share|improve this question






















  • Have you tried IsTabStop="false" ?
    – Sean O'Neil
    Apr 19 '18 at 10:58










  • Yeah, if IsTabStop="false" , then I can't edit the textbox.
    – Vincent
    Apr 19 '18 at 11:33










  • I can't seem to replicate this on my side. Could it be in the ScrollViewerAppleStyle? Could you try removing it now to check if it works without it?
    – Martin Zikmund
    Apr 19 '18 at 12:12










  • No,not that reason. You can try add many controls, to more than one page. then at the bottom of the page, click the blank area, the textbox always get focused.
    – Vincent
    Apr 19 '18 at 13:24






  • 1




    @Vincent try IsFocusEngagementEnabled="true" on the ScrollViewer. Also try wrapping the grid in an ItemsControl, which is a focusable container (although so is ScrollViewer). And yeah you can put stuff in GotFocus and LostFocus events. There are countless ways to hack your way out of this.
    – Sean O'Neil
    Apr 19 '18 at 23:52
















2














enter image description here



As the gif shows, My textbox is at the top of the scrollviewer. But when I scroll down, and click the blank area, the textbox always get focused.



It's annoying.



How to remove the textbox's auto focused?



    <ScrollViewer Grid.Row="1" Padding="5" Style="{StaticResource ScrollViewerAppleStyle}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition MinHeight="100" MaxHeight="400"/>
<RowDefinition Height="60"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="60"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="60"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="60"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="60"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="60"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="60"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>

<TextBox Text="欢迎使用小冰科技最新研发的自然语言处理程序。" x:Name="textInput" x:Uid="textBox_Input" TabIndex="-1" BorderBrush="Gray" BorderThickness="1" TextWrapping="Wrap" AcceptsReturn="True" Style="{StaticResource TransparentBackgroundTextBoxStyle}" ScrollViewer.VerticalScrollBarVisibility="Auto"/>

Other controls.......

</Grid>
</ScrollViewer>









share|improve this question






















  • Have you tried IsTabStop="false" ?
    – Sean O'Neil
    Apr 19 '18 at 10:58










  • Yeah, if IsTabStop="false" , then I can't edit the textbox.
    – Vincent
    Apr 19 '18 at 11:33










  • I can't seem to replicate this on my side. Could it be in the ScrollViewerAppleStyle? Could you try removing it now to check if it works without it?
    – Martin Zikmund
    Apr 19 '18 at 12:12










  • No,not that reason. You can try add many controls, to more than one page. then at the bottom of the page, click the blank area, the textbox always get focused.
    – Vincent
    Apr 19 '18 at 13:24






  • 1




    @Vincent try IsFocusEngagementEnabled="true" on the ScrollViewer. Also try wrapping the grid in an ItemsControl, which is a focusable container (although so is ScrollViewer). And yeah you can put stuff in GotFocus and LostFocus events. There are countless ways to hack your way out of this.
    – Sean O'Neil
    Apr 19 '18 at 23:52














2












2








2







enter image description here



As the gif shows, My textbox is at the top of the scrollviewer. But when I scroll down, and click the blank area, the textbox always get focused.



It's annoying.



How to remove the textbox's auto focused?



    <ScrollViewer Grid.Row="1" Padding="5" Style="{StaticResource ScrollViewerAppleStyle}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition MinHeight="100" MaxHeight="400"/>
<RowDefinition Height="60"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="60"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="60"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="60"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="60"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="60"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="60"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>

<TextBox Text="欢迎使用小冰科技最新研发的自然语言处理程序。" x:Name="textInput" x:Uid="textBox_Input" TabIndex="-1" BorderBrush="Gray" BorderThickness="1" TextWrapping="Wrap" AcceptsReturn="True" Style="{StaticResource TransparentBackgroundTextBoxStyle}" ScrollViewer.VerticalScrollBarVisibility="Auto"/>

Other controls.......

</Grid>
</ScrollViewer>









share|improve this question













enter image description here



As the gif shows, My textbox is at the top of the scrollviewer. But when I scroll down, and click the blank area, the textbox always get focused.



It's annoying.



How to remove the textbox's auto focused?



    <ScrollViewer Grid.Row="1" Padding="5" Style="{StaticResource ScrollViewerAppleStyle}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition MinHeight="100" MaxHeight="400"/>
<RowDefinition Height="60"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="60"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="60"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="60"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="60"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="60"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="60"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>

<TextBox Text="欢迎使用小冰科技最新研发的自然语言处理程序。" x:Name="textInput" x:Uid="textBox_Input" TabIndex="-1" BorderBrush="Gray" BorderThickness="1" TextWrapping="Wrap" AcceptsReturn="True" Style="{StaticResource TransparentBackgroundTextBoxStyle}" ScrollViewer.VerticalScrollBarVisibility="Auto"/>

Other controls.......

</Grid>
</ScrollViewer>






uwp textbox uwp-xaml






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Apr 19 '18 at 9:45









Vincent

267112




267112












  • Have you tried IsTabStop="false" ?
    – Sean O'Neil
    Apr 19 '18 at 10:58










  • Yeah, if IsTabStop="false" , then I can't edit the textbox.
    – Vincent
    Apr 19 '18 at 11:33










  • I can't seem to replicate this on my side. Could it be in the ScrollViewerAppleStyle? Could you try removing it now to check if it works without it?
    – Martin Zikmund
    Apr 19 '18 at 12:12










  • No,not that reason. You can try add many controls, to more than one page. then at the bottom of the page, click the blank area, the textbox always get focused.
    – Vincent
    Apr 19 '18 at 13:24






  • 1




    @Vincent try IsFocusEngagementEnabled="true" on the ScrollViewer. Also try wrapping the grid in an ItemsControl, which is a focusable container (although so is ScrollViewer). And yeah you can put stuff in GotFocus and LostFocus events. There are countless ways to hack your way out of this.
    – Sean O'Neil
    Apr 19 '18 at 23:52


















  • Have you tried IsTabStop="false" ?
    – Sean O'Neil
    Apr 19 '18 at 10:58










  • Yeah, if IsTabStop="false" , then I can't edit the textbox.
    – Vincent
    Apr 19 '18 at 11:33










  • I can't seem to replicate this on my side. Could it be in the ScrollViewerAppleStyle? Could you try removing it now to check if it works without it?
    – Martin Zikmund
    Apr 19 '18 at 12:12










  • No,not that reason. You can try add many controls, to more than one page. then at the bottom of the page, click the blank area, the textbox always get focused.
    – Vincent
    Apr 19 '18 at 13:24






  • 1




    @Vincent try IsFocusEngagementEnabled="true" on the ScrollViewer. Also try wrapping the grid in an ItemsControl, which is a focusable container (although so is ScrollViewer). And yeah you can put stuff in GotFocus and LostFocus events. There are countless ways to hack your way out of this.
    – Sean O'Neil
    Apr 19 '18 at 23:52
















Have you tried IsTabStop="false" ?
– Sean O'Neil
Apr 19 '18 at 10:58




Have you tried IsTabStop="false" ?
– Sean O'Neil
Apr 19 '18 at 10:58












Yeah, if IsTabStop="false" , then I can't edit the textbox.
– Vincent
Apr 19 '18 at 11:33




Yeah, if IsTabStop="false" , then I can't edit the textbox.
– Vincent
Apr 19 '18 at 11:33












I can't seem to replicate this on my side. Could it be in the ScrollViewerAppleStyle? Could you try removing it now to check if it works without it?
– Martin Zikmund
Apr 19 '18 at 12:12




I can't seem to replicate this on my side. Could it be in the ScrollViewerAppleStyle? Could you try removing it now to check if it works without it?
– Martin Zikmund
Apr 19 '18 at 12:12












No,not that reason. You can try add many controls, to more than one page. then at the bottom of the page, click the blank area, the textbox always get focused.
– Vincent
Apr 19 '18 at 13:24




No,not that reason. You can try add many controls, to more than one page. then at the bottom of the page, click the blank area, the textbox always get focused.
– Vincent
Apr 19 '18 at 13:24




1




1




@Vincent try IsFocusEngagementEnabled="true" on the ScrollViewer. Also try wrapping the grid in an ItemsControl, which is a focusable container (although so is ScrollViewer). And yeah you can put stuff in GotFocus and LostFocus events. There are countless ways to hack your way out of this.
– Sean O'Neil
Apr 19 '18 at 23:52




@Vincent try IsFocusEngagementEnabled="true" on the ScrollViewer. Also try wrapping the grid in an ItemsControl, which is a focusable container (although so is ScrollViewer). And yeah you can put stuff in GotFocus and LostFocus events. There are countless ways to hack your way out of this.
– Sean O'Neil
Apr 19 '18 at 23:52












2 Answers
2






active

oldest

votes


















0














I have also experienced this slightly annoying bug, which when in conjunction with a ScrollViewer leads to very undesired behavior.



It seems that when you loose focus of a previously focused control, another control will have to be assigned the focus.
The TextBox is the first control "focus-able" on your page and therefore it will be the one to to be given focus, which leads to the ScrollViewerbeing forced to change its view to the vertical offset where the TextBox is defined at.



The easiest possible option would be to handle the LostFocus event, and assign the focus to another control which wouldn't cause such a notable issue.



The reason why this behavior happens I guess is to not ruin the experience of keyboard-only users.






share|improve this answer



















  • 1




    Yeah, Only if a TextBox in a ScrollViewer, this happens.😭😭😭
    – Vincent
    Apr 19 '18 at 13:33










  • @Vincent Indeed! Can you try to set your Button IsTabStop dependency property to false. This way they won't steal the focus from the TextBox, which should prevent the auto focus which is later given to the textbox, which chains a ScrollViewer ChangeView event.
    – André B
    Apr 19 '18 at 15:41



















0














I had this same problem it had got easily fixed when the IsTabStop property of ScrollViewer is set to True.



<ScrollViewer IsTabStop="True">
//your code with TextBox in here
</ScrollViewer>





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%2f49917853%2fwhy-is-textbox-is-always-geting-focus-when-i-click-the-blank-area-of-the-page%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














    I have also experienced this slightly annoying bug, which when in conjunction with a ScrollViewer leads to very undesired behavior.



    It seems that when you loose focus of a previously focused control, another control will have to be assigned the focus.
    The TextBox is the first control "focus-able" on your page and therefore it will be the one to to be given focus, which leads to the ScrollViewerbeing forced to change its view to the vertical offset where the TextBox is defined at.



    The easiest possible option would be to handle the LostFocus event, and assign the focus to another control which wouldn't cause such a notable issue.



    The reason why this behavior happens I guess is to not ruin the experience of keyboard-only users.






    share|improve this answer



















    • 1




      Yeah, Only if a TextBox in a ScrollViewer, this happens.😭😭😭
      – Vincent
      Apr 19 '18 at 13:33










    • @Vincent Indeed! Can you try to set your Button IsTabStop dependency property to false. This way they won't steal the focus from the TextBox, which should prevent the auto focus which is later given to the textbox, which chains a ScrollViewer ChangeView event.
      – André B
      Apr 19 '18 at 15:41
















    0














    I have also experienced this slightly annoying bug, which when in conjunction with a ScrollViewer leads to very undesired behavior.



    It seems that when you loose focus of a previously focused control, another control will have to be assigned the focus.
    The TextBox is the first control "focus-able" on your page and therefore it will be the one to to be given focus, which leads to the ScrollViewerbeing forced to change its view to the vertical offset where the TextBox is defined at.



    The easiest possible option would be to handle the LostFocus event, and assign the focus to another control which wouldn't cause such a notable issue.



    The reason why this behavior happens I guess is to not ruin the experience of keyboard-only users.






    share|improve this answer



















    • 1




      Yeah, Only if a TextBox in a ScrollViewer, this happens.😭😭😭
      – Vincent
      Apr 19 '18 at 13:33










    • @Vincent Indeed! Can you try to set your Button IsTabStop dependency property to false. This way they won't steal the focus from the TextBox, which should prevent the auto focus which is later given to the textbox, which chains a ScrollViewer ChangeView event.
      – André B
      Apr 19 '18 at 15:41














    0












    0








    0






    I have also experienced this slightly annoying bug, which when in conjunction with a ScrollViewer leads to very undesired behavior.



    It seems that when you loose focus of a previously focused control, another control will have to be assigned the focus.
    The TextBox is the first control "focus-able" on your page and therefore it will be the one to to be given focus, which leads to the ScrollViewerbeing forced to change its view to the vertical offset where the TextBox is defined at.



    The easiest possible option would be to handle the LostFocus event, and assign the focus to another control which wouldn't cause such a notable issue.



    The reason why this behavior happens I guess is to not ruin the experience of keyboard-only users.






    share|improve this answer














    I have also experienced this slightly annoying bug, which when in conjunction with a ScrollViewer leads to very undesired behavior.



    It seems that when you loose focus of a previously focused control, another control will have to be assigned the focus.
    The TextBox is the first control "focus-able" on your page and therefore it will be the one to to be given focus, which leads to the ScrollViewerbeing forced to change its view to the vertical offset where the TextBox is defined at.



    The easiest possible option would be to handle the LostFocus event, and assign the focus to another control which wouldn't cause such a notable issue.



    The reason why this behavior happens I guess is to not ruin the experience of keyboard-only users.







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Apr 19 '18 at 12:59

























    answered Apr 19 '18 at 12:54









    André B

    1,2851518




    1,2851518








    • 1




      Yeah, Only if a TextBox in a ScrollViewer, this happens.😭😭😭
      – Vincent
      Apr 19 '18 at 13:33










    • @Vincent Indeed! Can you try to set your Button IsTabStop dependency property to false. This way they won't steal the focus from the TextBox, which should prevent the auto focus which is later given to the textbox, which chains a ScrollViewer ChangeView event.
      – André B
      Apr 19 '18 at 15:41














    • 1




      Yeah, Only if a TextBox in a ScrollViewer, this happens.😭😭😭
      – Vincent
      Apr 19 '18 at 13:33










    • @Vincent Indeed! Can you try to set your Button IsTabStop dependency property to false. This way they won't steal the focus from the TextBox, which should prevent the auto focus which is later given to the textbox, which chains a ScrollViewer ChangeView event.
      – André B
      Apr 19 '18 at 15:41








    1




    1




    Yeah, Only if a TextBox in a ScrollViewer, this happens.😭😭😭
    – Vincent
    Apr 19 '18 at 13:33




    Yeah, Only if a TextBox in a ScrollViewer, this happens.😭😭😭
    – Vincent
    Apr 19 '18 at 13:33












    @Vincent Indeed! Can you try to set your Button IsTabStop dependency property to false. This way they won't steal the focus from the TextBox, which should prevent the auto focus which is later given to the textbox, which chains a ScrollViewer ChangeView event.
    – André B
    Apr 19 '18 at 15:41




    @Vincent Indeed! Can you try to set your Button IsTabStop dependency property to false. This way they won't steal the focus from the TextBox, which should prevent the auto focus which is later given to the textbox, which chains a ScrollViewer ChangeView event.
    – André B
    Apr 19 '18 at 15:41













    0














    I had this same problem it had got easily fixed when the IsTabStop property of ScrollViewer is set to True.



    <ScrollViewer IsTabStop="True">
    //your code with TextBox in here
    </ScrollViewer>





    share|improve this answer


























      0














      I had this same problem it had got easily fixed when the IsTabStop property of ScrollViewer is set to True.



      <ScrollViewer IsTabStop="True">
      //your code with TextBox in here
      </ScrollViewer>





      share|improve this answer
























        0












        0








        0






        I had this same problem it had got easily fixed when the IsTabStop property of ScrollViewer is set to True.



        <ScrollViewer IsTabStop="True">
        //your code with TextBox in here
        </ScrollViewer>





        share|improve this answer












        I had this same problem it had got easily fixed when the IsTabStop property of ScrollViewer is set to True.



        <ScrollViewer IsTabStop="True">
        //your code with TextBox in here
        </ScrollViewer>






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Dec 27 '18 at 16:16









        Vignesh

        659215




        659215






























            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.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • 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%2f49917853%2fwhy-is-textbox-is-always-geting-focus-when-i-click-the-blank-area-of-the-page%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







            A2zLwGyrrG,Q,5INmanLR,1omFTIpTk06MD3jZQzv rlVIDh5JLH,PSo8z4dO1b3FaUh72ciVL8433,lrUjD yfaHvbcWfX1rO BN
            dv PjrlL4hkFHhOMKx t8B JAD NDG8cfrJfQdKQYCacXzl,04e,X6JYVgXmr13SvH JkLxbBsLCQ4ea4y

            Popular posts from this blog

            Monofisismo

            Angular Downloading a file using contenturl with Basic Authentication

            Olmecas