Tutorials for web designers and developers
Tutorials for Developers_

How to Share text in windows 8.1 app? (Download Project) (Video Tutorial , Tutorial Files)


Searching in App Tutorial: (Download Project)

1. Create a blank windows 8.1 store app in c#

2. goto MainPage.xaml and following lines of code between opening and closing tag of GRID

    <StackPanel VerticalAlignment="Center">
            <TextBlock FontSize="60" HorizontalAlignment="Center" Name="TextBlockContent">Hello  World</TextBlock>     
    </StackPanel>

3. Goto MainPage.xaml.cs and in side public sealed partial class replace code with following code:
Note: You will see red squiggly line under SearchPaneQuerySubmittedEventArgs and SearchPane, goto them and resolve by right clicking on them and selecting resolve.

public MainPage()
        {
            this.InitializeComponent();
            SearchPane.GetForCurrentView().QuerySubmitted += MainPage_QuerySubmitted;
            SearchPane.GetForCurrentView().SuggestionsRequested += MainPage_SuggestionsRequested;
        }

        void MainPage_SuggestionsRequested(SearchPane sender, SearchPaneSuggestionsRequestedEventArgs args)
        {
            if(args.QueryText.StartsWith("a"))
            {
                args.Request.SearchSuggestionCollection.AppendQuerySuggestion("Apple");
                args.Request.SearchSuggestionCollection.AppendQuerySuggestion("Ant");
                args.Request.SearchSuggestionCollection.AppendQuerySuggestion("Arrow");
            }
            else if (args.QueryText.StartsWith("b"))
            {
                args.Request.SearchSuggestionCollection.AppendQuerySuggestion("Bapple");
                args.Request.SearchSuggestionCollection.AppendQuerySuggestion("Bat");
                args.Request.SearchSuggestionCollection.AppendQuerySuggestion("Batman");
            }
            else
            {
                args.Request.SearchSuggestionCollection.AppendQuerySuggestion("Pakistan");
                args.Request.SearchSuggestionCollection.AppendQuerySuggestion("Cricket");
                args.Request.SearchSuggestionCollection.AppendQuerySuggestion("Match");
            }
        }

        void MainPage_QuerySubmitted(SearchPane sender, SearchPaneQuerySubmittedEventArgs args)
        {
            TextBlockContent.Text = args.QueryText;
        }

4. Now declare that your app wants to search by going to manifest file > declarations.

Screenshot (27)
 


How to implement PRIVACY POLICY? (Download Project)


Visual Studio Tips & Tricks (Download Power point file)

 

Leave a Reply

Your email address will not be published. Required fields are marked *