无法在放置在<controls:pageheader.primarycommands>中的TextBox中设置焦点和类型文本

时间:2017-05-10 20:03:10

标签: c# wpf xaml template10

我正在使用Template10。这部分代码创建了一个名为searchTextBox和按钮的TextBox工具栏。问题是我无法将任何字符写入TextBox。我可以通过右键单击粘贴一些文本。此TextBox已启用且不是只读的。

   <!--  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>

2 个答案:

答案 0 :(得分:0)

Visual Studio团队专家将此问题确定为UWP中的错误。

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

答案 1 :(得分:0)

最后,我使用了两个标题来显示第二个文本标题以进行搜索。

    <!--  page header  -->
    <controls:PageHeader x:Name="pageHeader" x:Uid="LoadViewHeader" Width="auto" 
                         RelativePanel.AlignLeftWithPanel="True" RelativePanel.AlignTopWithPanel="True" RelativePanel.LeftOf="searchPageHeader">
        <controls:PageHeader.SecondaryCommands>
            <AppBarButton Label="Settings" />
        </controls:PageHeader.SecondaryCommands>
    </controls:PageHeader>

    <!--  searching header  -->
    <controls:PageHeader x:Name="searchPageHeader" Width="auto" EllipsisVisibility="Collapsed"
               RelativePanel.AlignTopWithPanel="True" RelativePanel.AlignRightWithPanel="True">
        <controls:PageHeader.Content>
            <AutoSuggestBox Name="searchTextBox" x:Uid="LoadViewSearchBox" Width="250" Height="32" Margin="0,8,8,0" QueryIcon="Find" >
                <interactivity:Interaction.Behaviors>
                <core:EventTriggerBehavior EventName="QuerySubmitted">
                    <core:InvokeCommandAction Command="{x:Bind ViewModel.SearchCommand}" />
                </core:EventTriggerBehavior>
                </interactivity:Interaction.Behaviors>
            </AutoSuggestBox>

        </controls:PageHeader.Content>
    </controls:PageHeader>