Integrated settings, help, search, and sharing for Windows app development

Source: Internet
Author: User

App settings and app help "settings" contract

In the previous section, we learned how to save app settings locally. The way to do this is by adding the settings option within the app, here's another way.

Microsoft calls it a "setup" contract, and all Windows store apps take their own initiative to work with such contracts.

But the application comes with a setup that assumes that no matter what changes are made, it is useless. And we add these settings to make the app more personal.

Settingsflyout

First create a new Settingsflyout page, perhaps a lot of children's shoes will be like I learned this at once the debug program wait to see what this setting is like. I just can't use it now.

For example, see below. We can alter the iconsource to change the icon in the "Settings".

Then I will set the layout settings for the interface such as the following.

<StackPanel verticalalignment= "Stretch"horizontalalignment=" Stretch " Orientation=" Vertical ">      <StackPanel Orientation="Vertical" >         <TextBlock Text="Big Car's Beautiful Day" FontSize="  Foreground="Red" Margin="/> "         <textblock  Text  =< Span class= "Hljs-value" > "buying a big car will make your life vibrant and passionate!" " fontsize  ="  " margin  = "all"   textwrapping  = "Wrap"  foreground  = "Black" />          <TextBlock Text="If you want to buy the words can be sent directly mail [email protected]" FontSize=" Margin="Foreground" = "Gold" textwrapping="Wrap"/>       </StackPanel>    <StackPanel Orientation= "Vertical" Margin="8">          <toggleswitch  x:Name  = "toggleSwitch1"  header  =" update the latest pictures of big car daily " oncontent  =" on " offcontent  =" Off " toggled  =/>          <toggleswitch x:name="ToggleSwitch2" Header="Push related updates to me"  Oncontent="On" offcontent= "Off" toggled="toggleswitch_toggled"  IsOn="True"/>     </StackPanel>     <StackPanel Orientation= "Vertical" Margin="0,12,0,12" >         <button Content="Praise the Application Bai" Margin="/> "         <button Content="Clear all Caches" Margin="/> "    </StackPanel></StackPanel>
App.xaml.cs

First add the following namespace to the App.xaml.cs, and the following 3 methods

using Windows.UI.ApplicationSettings;
protected Override void onwindowcreated(Windowcreatedeventargs args) {Settingspane.getforcurrentview (). commandsrequested + = oncommandsrequested;}Private void oncommandsrequested(Settingspane Sender,settingspanecommandsrequestedeventargs args) {args. REQUEST.APPLICATIONCOMMANDS.ADD (NewSettingscommand ("Bigcarmainsettings","Big Car's main setting", (handler) = Showcustomsettingflyout ()));} Public void Showcustomsettingflyout() {Bigcarsettings customsettingflyout =NewBigcarsettings (); Customsettingflyout.show ();}

Of course, the last of the clicks in those controls will be added to the backend code. Just like the previous blog to save the settings just fine.

These are the same things about the app settings. and application Help. And these are the same.

It's good to create the same goal.

And then change it in XAML to look like it. And the same as the application settings. We can also set the app bar at the bottom of the app bar to see the "App Bar" section of chapter three.

protected  override  Span class= "Hljs-keyword" >void onwindowcreated  (Windowcreatedeventargs args ) {Settingspane.getforcurrentview (). commandsrequested + = oncommandsrequested;} private  void  oncommandsrequested  (Settingspane sender, Settingspanecommandsrequestedeventargs args) {args. REQUEST.APPLICATIONCOMMANDS.ADD (new  Settingscommand (  "Bigcarhelp" ,  "Big Car Help" , (handler) = Showhelpsettingsflyout ()));} public  void  showhelpsettingsflyout  () {BIGCARHELPHELPSF = new  bigcarhelp (); Helpsf.show ();} 
Integrate search in your app

The previous section is about how to add app settings and help, which is a similar search for settings.

So ... Let's do it!

Start with a simple page layout. Think about what we need, a button with a search event. Also need some TextBlock to prompt the user, the core part is naturally a gridview slightly.

<Grid Background="Wheat">        <grid.rowdefinitions>            <rowdefinition Height="Auto" />            <rowdefinition />        </grid.rowdefinitions>        <stackpanel  Grid.Row  = "0"  orientation  =  "Vertical" ;             <button  Grid.Row  =  "0"  name  = "btnsearch"  verticalalignment  = "Center"  horizontalalignment  =" left " content  =" search " fontfamily  = "Chinese Xingkai"  click  = "Btnsearch_ Click " margin  ="  fontsize  ="  class= Hljs-attribute  = "Red" />             <StackPanel Orientation="Horizontal">                <TextBlock Text="search keyword" Foreground="Green" FontSize ="$" Margin="/> "                <TextBlock FontSize=" Foreground" = "Green" Name= "Tblockkeyword" Margin="/> "            </StackPanel>                           </StackPanel>        <GridView grid.row="1" Margin=" x:name" ="GridView">            <gridview.itemspanel>                <itemspaneltemplate>                    <wrapgrid Orientation="Horizontal"/>                </itemspaneltemplate>            </gridview.itemspanel>            <gridview.itemtemplate>                <DataTemplate>                    <TextBlock Text="{Binding}" FontSize=" Foreground " ="Pink" FontFamily="italic"/>                </DataTemplate>            </gridview.itemtemplate>        </GridView>    </Grid>

Now that the interface is finished, it's time to go backstage and tinker with it. The core of the search is Searchpane, so let's instantiate it first. To simplify. We'll set the content to be searched as a string array. All right, of course. The way you initialize an array is just as good as everyone else.

searchpane Searchpane = null ; Span class= "Hljs-keyword" >string  [] examplestr = new  string  [100 ];  public  void  initexamplestr      () {Random ran = new  random ();     int  exnumber; for  (int  i=0 ; I<100 ; i++) {Exnumber = ran.          Next (1000 , 9999 );                                   Examplestr[i] = exnumber.tostring (); }                                                                                     }

The Searchpane_querychange event is triggered when a user enters something in the search box that changes.

The searchpane_querysubmitted event is triggered when the user presses the ENTER key after completing the input or clicks the Search confirmation button next to it.

        void searchPane_QueryChanged(SearchPane sender, SearchPaneQueryChangedEventArgs args)        {                                                 this.tBlockKeyword.Text = args.QueryText;        }        void searchPane_QuerySubmitted(SearchPane sender, SearchPaneQuerySubmittedEventArgs args)        {                   string key = args.QueryText;            var result = exampleStr.Where(s => s.Contains(key))

Windows App开发之集成设置、帮助、搜索和共享

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.