how to create an auto complete search textbox in windows 8 - c#

I found that Windows 8 textbox has a property "IsPredictionEnabled". I understand it is used for enable autocomplete features. But setting this property has no effect even with soft keyboards.
And If i want this search textbox to search bing and retrieve some images corresponding to the search query, how can this be done?
Thank you,

Better use a cutsom control like this:
AutoCompleteBoxWinRT
To get search results from bing You need to use bind api:
Bing API
To use AutCompleteBoxWinRT:
Import namespace:
xmlns:ab="using:AutoCompleteBox"
Place control:
<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
<ab:AutoCompleteBox Name="ABBox" Text="{Binding Text, Mode=TwoWay}" WatermarkText="Type something" />
<Button Content="Test" VerticalAlignment="Top" Margin="0,100,0,0" Command="{Binding TestCommand}" />
</Grid>
Here You can download a sample app: LINK

Related

print from resources (resw) directly in view on uwp | WPF

Hi guys i'm building a Universal Windows App for windows 10 IOT.
So, I'didn't found a method to get a label value from resources file, directly from WPF.
There is a method like this:
<Button Content="{x:StaticResources local:mylabel" Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center" Name="btnUpdate" Margin="0,200,0,0" MinWidth="300" Command="{Binding add}" />
on the "normal" WPF it's easy, but on universal windows app I didn't
found a solution.
The resources file within on Resources folder in my solution, while the page it's in view folder.
Thanks
In UWP you can use x:Uid directive to associate a control with a string resource identifier:
<Button x:Uid="mylabel" Name="btnUpdate" .... Command="{Binding add}" />
Please refer to MSDN for more information: https://learn.microsoft.com/en-us/windows/uwp/app-resources/localize-strings-ui-manifest

How do I use a button in Windows Phone 8 hub app

I am trying to change the context of a button inside a DataTemplate, but in my code-behind I can't acses it. What am I doing wrong?
Here is the XAML I am using:
<Grid>
<Hub>
<HubSection>
<DataTemplate>
<Grid>
<Button x:Name="THEbutten" Content="Button" HorizontalAlignment="Left" Margin="186,230,0,0" VerticalAlignment="Top"/>
</Grid>
</DataTemplate>
</HubSection>
</Hub>
</Grid>
Your Button is inside a DataTemplate, and therefore it is in a different context than the page and not accessible from it's codebehind.
Consider the following options:
Modify your Buttons Properties using Data Binding.
Create a UserControl for your HubSections Content.
Sadly, the Hub Control is fairly hard to understand and use for beginners, because of this DataTemplate.
Here are some tutorials:
Mikaelkoskinen - Getting started
DotNetCurry - The Windows 8.1 Hub Control
There are also several questions around here on that topic:
How to access controls within hubsections

Add popup menu to AppBarButton

I want to add a contextual menu to a button from the appBar(bottom appBar). My min SDK is Windows 8.0. I would like something like this popup from MSDN:
Unfortunately I cannot use MenuFlyout since it is available only from Windows 8.1+, so I want to achieve this menu in another way. If you know how it can be done, please tell me.
Below is my bottom bar:
<common:LayoutAwarePage.BottomAppBar>
<AppBar x:Name="bottomAppBar" Padding="10,0,10,0" DataContext="{Binding}">
<Grid>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
<Button Style="{StaticResource EditAppBarButtonStyle}" Click="EditQuote_Click"/>
<Button Style="{StaticResource RemoveAppBarButtonStyle}" Click="RemoveQuote_Click"/>
<Button Style="{StaticResource AddAppBarButtonStyle}" Click="AddQuote_Click"/>
</StackPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
<Button Style="{StaticResource HelpAppBarButtonStyle}"/>
</StackPanel>
</Grid>
</AppBar>
You should take a look at the Flyout Settings sample at:
http://code.msdn.microsoft.com/windowsapps/Settings-Flyout-eceaafea
Or if you are targeting Windows 8.1, flyouts have become much easier, check the MenuFlyout element:
http://msdn.microsoft.com/en-us/library/windows/apps/bg182878.aspx#menuflyout
I would look at the Callisto library on Nuget. It's built by Tim Heuer who's one of the guys working on the xaml team at Microsoft and fills in some of the gaps in the 8.0 control set. It includes a Menu Flyout control that looks not that coincidentally like the controls added in 8.1.
The samples app in the project includes an example of what you're looking for (a Menu Flyout from an App Bar).
Edit: If you're targeting Windows 8.1 with your project then the Menu Flyout control is now built into the platform.

windows phone 8 show blank map

I am trying to add a simple map to my app.
I added map reference, added capability in WMAppManifest and this code to page:
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<maps:Map x:Name="MyMap" Center="47.6097, -122.3331" ZoomLevel="10" HorizontalAlignment="Left" VerticalAlignment="Top" Loaded="Map_Loaded_1" />
</Grid>
but it show blank map. What I mean blank? a black page!
I can not get it to work. tell me what I missed!?
Try to follow this guide step by step, and see if it helps.
http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj207045(v=vs.105).aspx
Maybe your internet connection is dead (or just not configured properly in emulator)?

How to add rows to gridview dynamically in windows phone 7.1 application?

in my window phone 7.1 application(silverlight application, c# language using VS 2010 express for windows phone) i created gridview to show my data(search results) in table format. I created a class and bound that gridview to that class succussfully. this is my xaml code:
<phone:PhoneApplicationPage.Resources>
<local:searchResultItemModel x:Key="searchResultIM"/>
</phone:PhoneApplicationPage.Resources>
<gridView:GridView x:Name="GridView1" CellSpacing="1" RowSpacing="1" SelectedItemChanged="GridViewSelectedItemChanged" Margin="26,16,25,22" ItemsSource="{Binding Source={StaticResource searchResultIM}, Path=Data}">
But i want to add rows dynamically. As this is static i cant able to add rows to it. Is anyother way to add rows dynamically. Could anybody help me please?
You have to use the ListBox Control and template it to your liking. The ListBox also includes bunch of features like UIVitualization that will help with bigger sets of data.
As said you can use the ListBox with a datatemplate to control the look of each row. Example:
<ListBox ItemsSource="{Binding Source={StaticResource searchResultIM}, Path=Data}" ItemTemplate="{StaticResource SearchItemTemplate}" />
Put the above ListBox element inside your LayoutRoot (usually a Grid control) in your Phone page. In the ListBox you will refer to the ItemTemplate to use (defined as DataTemplate) which you define in your resources section, example:
<DataTemplate x:Name="SearchItemTemplate">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding YourDataProperty1}" />
<TextBlock Text="{Binding YourDataProperty2}" Grid.Column="1" />
</Grid>
</DataTemplate>
The datacontext for the template will be the type of object you get in your results. So YourDataProperty1 etc could be a property on that resultobject.
Hope it helps!
/Anders
Building a DataGrid Control for Silverlight for Windows Phone
http://www.silverlightshow.net/items/Building-a-DataGrid-Control-for-Silverlight-for-Windows-Phone-Part-1.aspx
This suits the way to create a dynamic table perfectly, The problem in using list box is if the contents goes beyind windows phone, its not easy then to create table using listbox. This grid control has lot of features that would help a newbie like me. Its totally intuitive

Categories