InputScopeを検索に設定し、キーアップイベントを処理し、キーが入力されている場合にフォーカスを呼び出すことによって、以前に「閉じる」ボタンをSIPに追加しました。WP7ユーザーコントロールでSIPを閉じる方法
私は、テキストブロックとテキストボックスを含むユーザーコントロールで同じことをやろうとしましたが、sipだけが閉じません。ここで
は、ユーザーコントロールです:
XAML
<UserControl
x:Class="SlidePanels.UserControls.TextBoxControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
d:DesignWidth="480">
<StackPanel
Orientation="Vertical"
Background="{StaticResource PhoneChromeBrush}">
<TextBlock
x:Name="LabelControl"
Text="Label Control"
Style="{StaticResource PhoneTextNormalStyle}" />
<TextBox
x:Name="TextControl"
Text="Text Control"
InputScope="Search"
KeyUp="TextControl_KeyUp" />
</StackPanel>
コード:
using System.Windows.Input;
namespace SlidePanels.UserControls
{
public partial class TextBoxControl
{
public TextBoxControl()
{
InitializeComponent();
}
public string FieldName { get; set; }
public string Label
{
set { LabelControl.Text = value; }
}
public string Text
{
get { return TextControl.Text; }
set { TextControl.Text = value; }
}
private void TextControl_KeyUp(object sender, KeyEventArgs e)
{
if (e.Key == Key.Enter)
{
Focus();
}
}
}
}
私が間違ってやっている任意のアイデア?
しばしば議論のトピックのようだと私は提案としてこれを投稿します。http://wpdev.uservoice。 com/forums/110705-app-platform/suggestions/1910729-method-to-close-sip – CodeZombie