前台代码:
<Grid x:Name="LayoutRoot" Background="#666"> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> <RowDefinition Height="*"/> </Grid.RowDefinitions>
<!--TitlePanel 包含应用程序的名称和页标题--> <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28"> <TextBlock x:Name="ApplicationTitle" Text="我的应用程序" Style="{StaticResource PhoneTextNormalStyle}"/> <TextBlock x:Name="PageTitle" Text="搜索" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/> </StackPanel>
<!--ContentPanel - 在此处放置其他内容--> <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0"> <TextBox Height="72" HorizontalAlignment="Left" Margin="12,86,0,0" Name="txtKey" VerticalAlignment="Top" Width="460" /> <Button Content="搜索" Height="72" HorizontalAlignment="Left" Margin="480,86,0,0" Name="button1" VerticalAlignment="Top" Width="160" Click="button1_Click" /> </Grid> </Grid>
后台代码:
private void button1_Click(object sender, RoutedEventArgs e) { SearchTask searcher = new SearchTask(); searcher.SearchQuery = txtKey.Text; searcher.Show(); }