在商店应用/通用应用/ Windows Phone 8.1 Visual Studio 2013项目中,如何以编程方式选择TextBox中的所有文本,并启用上下文复制图标菜单,如下面的屏幕截图所示:
a busy cat http://texttophone.free.fr/selectallwithcopyenabled.png
需要在上下文中显示文本,用户很可能希望将其复制到剪贴板中。
以下测试不起作用:
XAML
<TextBox x:Name="MyTextBox" Grid.Row="0"
HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
Text="The text I want to select"
IsReadOnly="True"
IsEnabled="True"
GotFocus="MyTextBox_GotFocus"></TextBox>
<Button x:Name="ButtonSelectAll" Grid.Row="1"
Content="Select All"
HorizontalAlignment="Center"
Click="ButtonSelectAll_Click"></Button>
C#
private void ButtonSelectAll_Click(object sender, RoutedEventArgs e)
{
MyTextBox.SelectAll();
// MyTextBox.Focus(FocusState.Programmatic);
}
private void MyTextBox_GotFocus(object sender, RoutedEventArgs e)
{
MyTextBox.SelectAll();
}
尝试点击事件不执行任何操作。 尝试 GotFocus 事件选择所有文本,但上下文复制图标菜单和两个句柄不会显示。 如果您添加单击方法&#34; text.Focus(FocusState.Programmatic);&#34;然后选择文本但不显示复制图标。不幸的是,如果你用手指触摸这个文本,意图是&#34;复制图标&#34;将出现,你失去了选择。
答案 0 :(得分:0)
@efdummy试试这个:
$Date=date("Y/m/d");
$KonuBaslik=$_POST["baslik"];
$KonuCoverURL=$_POST["kapak"];
$icerik=htmlentities($_POST["konu_icerik"]);
$KonuIcerik=htmlentities($icerik);
$query="use blogdb;"."Start Transaction;".
"begin;"."set @ID=(select ifNull(MAX(konuID),0)+1 from konu);".
"INSERT INTO konu VALUES (?,?,?,'".$Date."',@ID);".
"commit;";
$mysqli = new mysqli($servername,$username, $password, $dbname);
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$stmt = $mysqli->prepare($query);
echo $mysqli->error;
$stmt->bind_param('sss', $KonuBaslik,$KonuIcerik,$KonuCoverURL);
$stmt->execute();