Search code examples
c#wpfxamltemplate10

Can not set focus and type text in TextBox placed in <controls:PageHeader.PrimaryCommands>


I am using Template10. This part of code create toolbar with TextBox named searchTextBox and button. Problem is I can not write any character to the TextBox . I can paste some text by right click. This TextBox is enabled and is not read only.

   <!--  header  -->
    <controls:PageHeader x:Name="pageHeader" x:Uid="LoadViewHeader"
                         RelativePanel.AlignLeftWithPanel="True" RelativePanel.AlignRightWithPanel="True" 
                         RelativePanel.AlignTopWithPanel="True">

        <!--  primary commands  -->
        <controls:PageHeader.PrimaryCommands>
            <AppBarButton Name="searchButton"  Width="250" Padding="0">
                <AppBarButton.Template>
                    <ControlTemplate>
                        <TextBox Name="searchTextBox" x:Uid="LoadViewSearchBox" Width="250" Height="32" Margin="0,8,0,0" 
                                 Text="{Binding Path=TextToSearch, Mode=TwoWay}" TextChanged="SearchTextBox_TextChanged" />

                    </ControlTemplate>
                </AppBarButton.Template>
            </AppBarButton>

            <AppBarButton Name="searchTextBoxButton" x:Uid="LoadViewSearchTextBoxButton" Icon="Find" Label="Search" />
            <AppBarSeparator/>
        </controls:PageHeader.PrimaryCommands>
    </controls:PageHeader>

Solution

  • Visual studio team expert identified this problem as error in UWP.

    See - https://developercommunity.visualstudio.com/content/problem/59249/text-box-in-page-header-is-partially-editable.html