AutoSuggestBox opens up off screen - xaml

I have probably the most basic implementation of AutoSuggestBox I can think of.
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid x:Name="SearchBoxContainer">
<AutoSuggestBox
PlaceholderText="Type a topic name"
Margin="8"
QueryIcon="Find"
DisplayMemberPath="Title"
TextChanged="AutoSuggestBox_TextChanged"
QuerySubmitted="AutoSuggestBox_QuerySubmitted"
SuggestionChosen="AutoSuggestBox_SuggestionChosen"
ItemsSource="{Binding MatchingTopics}"
/>
</Grid>
</Grid>
When typing in, I get a suggestion list. But it appears ABOVE the autoSuggestBox. The problem is that because I have placed the AutoSuggestBox at the top of the screen already, the suggestion list goes off screen so I can only see one item!
Is it possible to control the direction of the AutoSuggestBox so that it will expand downwards? Why doesn't the AutosuggestBox select the right direction based on available screen real estate?

Related

Narrator narrating UI element with `isTabStop=false`

I have one xaml page where there are multiple UI elements are there, and i wanted narrator to pick some UI element and ignore other. So with below code you can, see that I have four Grid Row Definition the last UI element is rendered on screen as Grid.RowSpan=4 and other UI elements also got intialized just for performance reason, but it won't be visible intially untill the last element Visibility will be set to Collapsed.
What i want when that "UserControlView1" control is rendered narrator should not pick other UI element, but once that is gone then narrator should start picking those UI element.
I have tried IsTabStop=false but not sure why it is not working.
<Page
xmlns:mvvm="using:Prism.Windows.Mvvm"
mvvm:ViewModelLocator.AutoWireViewModel="True"
// some random namespaces declaration
Loaded="PageLoaded">
<Grid>
<Grid.ColumnDefinitions>
// some Grid Column definition
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
// "4" Grid Row definition...
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<ctl:UserControlView2
x:Name="UserControlView2"
Grid.Row="1"
Grid.ColumnSpan="2"
IsTabStop="False"/>
<ctl:UserControlView3
x:Name="UserControlView2"
Grid.Row="2"
Grid.Column="0"
IsTabStop="False" --> I have set IsTabStop to false />
<ctl:UserControlView4
x:Name="UserControlView3"
Grid.Row="3"
Grid.Column="0"
IsTabStop="False" --> I have set IsTabStop to false />
<ctl:UserControlView1
d:Visibility="Collapsed"
x:Name="UserControlView1"
x:Load="{x:Bind ViewModel.UserControlView1}"
Grid.Row="0"
Grid.RowSpan="4" // as it span to four rows the reason being its gets render at top of the screen and other UI element will be there beneath it.
Grid.ColumnSpan="2"
TabIndex="0"/>
</Grid>
</Page>

Show layout on top of other pages and have it never close, even when contentpage changes

I am trying to achieve a layout that sits on top of all the other content views. And even when you navigate away from the current ContentView have the main layout remain on its position. I tried achieving this simply by showing a content view on top not in full screen, but even when I set a height property to the ContentView it will always display full screen.
So I decided to make three grids, two of which transparent and one with a solid background color.
Using the PopUp Plugin, this seemed to worked, however now you cannot click anything on the underlying content page because the transparent grid is still blocking the click.
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0" BackgroundColor="Transparent">
</Grid>
<Grid Grid.Row="1" BackgroundColor="Green">
</Grid>
<Grid Grid.Row="2" BackgroundColor="Transparent">
</Grid>
</Grid>
How would I go on about this?
I am fine with using a third party library.
Using the RG PopUp PlugIn this is achievable like so:
<pages:PopupPage
xmlns:pages="clr-namespace:Rg.Plugins.Popup.Pages;assembly=Rg.Plugins.Popup"
xmlns="http://xamarin.com/schemas/2014/forms"
HeightRequest="200"
BackgroundColor="#00000000"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:animations="clr-namespace:Rg.Plugins.Popup.Animations;assembly=Rg.Plugins.Popup"
mc:Ignorable="d"
InputTransparent="True"
x:Class="InteriorCircle.Pages.PopUps.PopUp_FloatingInfo">
<pages:PopupPage.Animation>
<animations:ScaleAnimation DurationIn="400"
DurationOut="300"
EasingIn="SinOut"
EasingOut="SinIn"
HasBackgroundAnimation="True"
PositionIn="Center"
PositionOut="Center"
ScaleIn="1.2"
ScaleOut="0.8" />
</pages:PopupPage.Animation>
<!-- takes whole page, so upper and lower grid are just to leave parts transparent-->
<Grid >
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="50"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0" BackgroundColor="Transparent" InputTransparent="true" >
</Grid>
<Grid Grid.Row="1" BackgroundColor="Transparent">
<BoxView BackgroundColor="White" CornerRadius="20"/>
</Grid>
</Grid>
</pages:PopupPage>

Screen that covers 80% of the screen

I am trying to create a windows 8.1 application and wanted to know that is there a control that allows me to create something like popup or messagebox in XAML that covers about 80% of the screen with some margin on either sides of the screen? Like when we click on a button and the screen's brightness gets dim except for the popup that is opened. As an example I have attached an image.Example from windows settings
Other than MessageBox there isn't an in-box control which does this. It's fairly easy to implement yourself in Xaml by creating a Grid with a partially opaque background and your controls in the middle of three rows. In this implementation the rows and columns will size to the controls placed in the center. You could also set those sizes more directly if you prefer.
<Grid Background="{ThemeResource DimmedBrush}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<!-- Coloured background for the center row -->
<Rectangle Grid.Row="1" Grid.ColumnSpan="3" Fill="{ThemeResource AppThemeBrush}" />
<!-- User control with the contents in the center row + column -->
<local:MyControls Grid.Row="1" Grid.Column="1" />
</Grid>
There are third party libraries which include controls like this. For example see Callisto's CustomDialog.

Nested Grouped ListView in XAML

I'm making a chatting app like WhatsApp. This is the layout I want to make,
Me(Static HeaderText)
MyInformation(Profile Image and name)
Favorites(Static HeaderText)
My Favorite friend information(Profile Image and name)
My Favorite friend
Friends(Static HeaderText)
A
My friend information(His name starts with A)
My friend
B
My friend
I implemented this with 3 listviews(Me, favorites, friends) in the Grid.
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid.Resources>
<CollectionViewSource x:Name="CollectionGroupedView" IsSourceGrouped="True" ItemsPath="Members" />
</Grid.Resources>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<ListView Grid.Row="0" x:Name="MeView" SelectionMode="None"
ItemTemplate="{StaticResource StandardTripleLineItemTemplate}"
Header="Me"
>
</ListView>
<ListView Grid.Row="1" x:Name="FavoriteView" SelectionMode="None"
ItemTemplate="{StaticResource StandardTripleLineItemTemplate}"
Header="Favorite"
>
</ListView>
<ListView Grid.Row="2" x:Name="FriendListView" SelectionMode="None"
ItemsSource="{Binding Source={StaticResource CollectionGroupedView}}"
ItemTemplate="{StaticResource StandardTripleLineItemTemplate}"
Header="Friends"
>
<ListView.GroupStyle>
<GroupStyle>
<GroupStyle.HeaderTemplate>
<DataTemplate>
<TextBlock Text="{Binding Key}" />
</DataTemplate>
</GroupStyle.HeaderTemplate>
</GroupStyle>
</ListView.GroupStyle>
</ListView>
</Grid>
And this is the result.
But as you can see, it doesn't work what I expected first.
The first problem is, each listview has its own ScrollView.
I need one outer scrollview. To solve this problem I tried to use StackPanel in the outside of listviews. But then scrollview has gone.
The second one is, when I scroll down the third listview, the header text Friends also scrolled. It shouldn't be.
If I can use nested CollectionViewSource, it might be possible. But I think there is no interfact like that.
How should I do layout this structure? Any experience or idea?
P.S Target Platform is Windows Phone 8.1. But I screen-captured it on WinRT application to show you the scrollbar.
1- for the whole scroll, one thought is that you can add your main grid in scrollview control in that case all the page will have one scroll.
here is how.
<ScrollViewer>
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid.Resources>
<CollectionViewSource x:Name="CollectionGroupedView" IsSourceGrouped="True" ItemsPath="Members" />
</Grid.Resources>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<ListView Grid.Row="0" x:Name="MeView" SelectionMode="None"
ItemTemplate="{StaticResource StandardTripleLineItemTemplate}"
Header="Me"
>
</ListView> .... </Grid></ScrollViewer>
You could try this: http://winrtxamltoolkit.codeplex.com/
It has a control called TreeView. Maybe that will help!

Docking Windows Phone controls to the bottom of a StackPanel

Is there a way to dock a Windows Phone control to the bottom of a StackPanel? This is my basic layout:
<StackPanel Orientation="Vertical">
<TextBlock />
<TextBlock />
<UI:AdControl />
</StackPanel>
My StackPanel is filling up the whole window. The TextBlocks are aligned toward the top of the panel, that's what I want.
But I want the AdControl to dock at the bottom of the StackPanel (and therefore the bottom of the window).
I've found controls like DockPanel, but they seem to only work for WPF or Silverlight as far as I can tell.
This can easily be accomplished with a simple grid
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
<Grid.RowDefinitions>
<StackPanel>
<TextBlock />
<TextBlock />
</StackPanel>
<UI:AdControl Grid.Row="1"/>
</Grid>
If you want exactly DockPanel for future use, make sure you look into open source implementations, there should be plenty of those out there!