首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >搜索框实现

问搜索框实现
EN

Stack Overflow用户
提问于 2014-06-25 05:42:10
回答 2查看 515关注 0票数 0

我正在windows phone 8上开发我的第一个应用程序。在这个应用程序中,我有一个搜索box.For --搜索框--我需要提供背景文本作为搜索城市(作为用户的提示文本)以及框内的搜索符号/搜索按钮,我能知道最好的方法吗?因为我在这个领域非常新。

提前谢谢。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2014-06-25 07:11:44

尝试这个水印(提示文本)在TextBox和搜索按钮在顶部。

xaml

代码语言:javascript
复制
<Grid x:Name="ContentPanel" Grid.Row="0" Margin="12,0,12,0" Width="440" Height="100">
        <TextBox Width="440" Name="txtSearch" Height="153" LostFocus="TextBox_LostFocus" GotFocus="TextBox_GotFocus" Text="This is whatever search..." TextWrapping="Wrap" Foreground="DarkGray" FontSize="18"></TextBox>
        <Button x:Name="btnSearch" Click="btnSearch_Click" HorizontalAlignment="Right" Height="70" Margin="0,0,10,0">
            <Button.Content>
                <Image Source="Images/yoursearchIcon.png"></Image>
            </Button.Content>
        </Button>
    </Grid>

代码背后

代码语言:javascript
复制
    private void TextBox_LostFocus(object sender, RoutedEventArgs e)
    {
        if (txtSearch.Text.Trim() == "")
        {
            txtSearch.Foreground = new SolidColorBrush(Colors.DarkGray);
            txtSearch.Text = "This is whatever search...";

        }
    }

    private void TextBox_GotFocus(object sender, RoutedEventArgs e)
    {
        if (txtSearch.Text == "This is whatever search...")
        {
            txtSearch.Foreground = new SolidColorBrush(Colors.Black);
            txtSearch.Text = "";

        }
    }

希望这能有所帮助

票数 0
EN

Stack Overflow用户

发布于 2014-06-25 05:45:49

您也可以使用AutoCompleteBox实现search功能。

查看一下这里

http://www.geekchamp.com/articles/autocompletebox-for-wp7-in-depth

希望能帮上忙!

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24400996

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档