I developed an UWP application that's having a wrong behavior on new version of Windows 10. In my application i have some ContentDialog with some TextBox inside them and when the soft-keyboard is shown it should push upwards the contentdialog but in new build of windows 10 this is not happening, anyone know why?
Here is a sample of my ContentDialog code:
<ContentDialog
x:Class="ManImp.CDEseguiOdM"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:ManImp"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
MaxHeight="{StaticResource ContentDialogMaxHeight}"
MaxWidth="{StaticResource ContentDialogMaxWidth}"
Margin="0"
Padding="0">
<Grid Background="{ThemeResource ApplicationBackGroudColor}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<!--0-->
<RowDefinition Height="Auto"></RowDefinition>
<!--0-->
<RowDefinition Height="Auto"></RowDefinition>
<!--1-->
<RowDefinition Height="Auto"></RowDefinition>
<!--2-->
<RowDefinition Height="Auto"></RowDefinition>
<!--3-->
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<StackPanel Orientation="Vertical" x:Name="stckLabelFirma" Grid.Row="0" Grid.Column="0">
<TextBlock x:Name="lblFirma" VerticalAlignment="Center" TextWrapping="Wrap" FontSize="24" Foreground="White" FontWeight="Normal" HorizontalAlignment="Center" Margin="0,0,0,5"></TextBlock>
</StackPanel>
<StackPanel Orientation="Vertical" Grid.Row="1" Grid.Column="0">
<InkToolbar InitialControls="None" VerticalAlignment="Top" HorizontalAlignment="Right" TargetInkCanvas="{x:Bind inkCanvasFirma}" >
<InkToolbarEraserButton />
<InkToolbarBallpointPenButton />
</InkToolbar>
<Grid BorderBrush="Black" BorderThickness="1">
<Image Name="imgFirma" Stretch="Uniform"></Image>
<InkCanvas x:Name="inkCanvasFirma" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"></InkCanvas>
</Grid>
</StackPanel>
<StackPanel Orientation="Vertical" x:Name="stckDatiSupProd" Grid.Row="2" Grid.Column="0">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"></ColumnDefinition>
<!--0-->
<ColumnDefinition Width="*"></ColumnDefinition>
<!--1-->
<ColumnDefinition Width="*"></ColumnDefinition>
<!--2-->
</Grid.ColumnDefinitions>
<StackPanel Orientation="Vertical" Grid.Column="0" Margin="0,10,5,0">
<TextBlock x:Name="lblCID" VerticalAlignment="Center" TextWrapping="Wrap" FontSize="20" Foreground="#FF034872" FontWeight="Bold" HorizontalAlignment="Left" Margin="0,0,0,0"></TextBlock>
<TextBox x:Name="txtCID" BorderBrush="Red" MaxLength="8" TextChanged="txtCID_TextChanged" VerticalAlignment="Center" Background="White" HorizontalAlignment="Stretch" Margin="0,10,0,0" TextWrapping="Wrap" FontSize="20"></TextBox>
</StackPanel>
<StackPanel Orientation="Vertical" Grid.Column="1" Margin="5,10,5,0">
<TextBlock x:Name="lblAlias" VerticalAlignment="Center" TextWrapping="Wrap" FontSize="20" Foreground="#FF034872" FontWeight="Bold" HorizontalAlignment="Left" Margin="0,0,0,0"></TextBlock>
<TextBox x:Name="txtAlias" BorderBrush="Red" TextChanged="txtAlias_TextChanged" VerticalAlignment="Center" Background="White" HorizontalAlignment="Stretch" Margin="0,10,0,0" TextWrapping="Wrap" FontSize="20"></TextBox>
</StackPanel>
<StackPanel Orientation="Vertical" Grid.Column="2" Margin="5,10,0,0">
<TextBlock x:Name="lblPIN" VerticalAlignment="Center" TextWrapping="Wrap" FontSize="20" Foreground="#FF034872" FontWeight="Bold" HorizontalAlignment="Left" Margin="0,0,0,0"></TextBlock>
<PasswordBox x:Name="txtPIN" BorderBrush="Red" PasswordChanged="txtPIN_PasswordChanged" VerticalAlignment="Center" Background="White" HorizontalAlignment="Stretch" Margin="0,10,0,0" FontSize="20"></PasswordBox>
</StackPanel>
</Grid>
</StackPanel>
<StackPanel Orientation="Vertical" Grid.Row="3" Grid.Column="0" Margin="0,10,0,0">
<TextBlock x:Name="lblErrore" Visibility="Collapsed" VerticalAlignment="Center" TextWrapping="Wrap" FontSize="14" Foreground="Red" FontWeight="Bold" HorizontalAlignment="Left" Margin="0,5,0,0"></TextBlock>
</StackPanel>
<StackPanel Orientation="Vertical" Grid.Row="4" Margin="0,10,0,0" Grid.Column="0">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"></ColumnDefinition>
<!--0-->
<ColumnDefinition Width="*"></ColumnDefinition>
<!--1-->
</Grid.ColumnDefinitions>
<Button x:Name="btnAnnulla" Grid.Column="0" HorizontalAlignment="Stretch" Margin="0,30,10,0" VerticalAlignment="Top" Click="btnAnnulla_Click"></Button>
<Button x:Name="btnConfFirmaSupProd" Grid.Column="1" HorizontalAlignment="Stretch" Margin="10,30,0,0" VerticalAlignment="Top" Click="btnConfFirmaSupProd_Click"></Button>
<Button x:Name="btnConfFirmaOperatore" Grid.Column="1" HorizontalAlignment="Stretch" Margin="10,30,0,0" VerticalAlignment="Top" Click="btnConfFirmaOperatore_Click"></Button>
</Grid>
</StackPanel>
</Grid>
This should be an issue related to the old SDK that when the app is targeting old versions like 14393.
If you really want to achieve this behavior on all versions of Windows 10. I'd suggest you handle the showing and hiding events manually via InputPane.Showing Event and InputPane.Hiding Event. And then you might need to customize a PopUp control that looks like a ContentDialog. We can't change the position of the ContentDialog, because it is handled by the system. But we could change the position of a PopUp control.
When the on-screen keyboard is shown, the showing event will be fired and you could try to manually move your PopUp control upwards. When the keyboard is hidden, just move the PopUp control back to its original position.
Here is the sample code about how to handle the show and hide event:
protected override void OnNavigatedTo(NavigationEventArgs e)
{
InputPane currentInputPane = InputPane.GetForCurrentView();
// Subscribe to Showing/Hiding events
currentInputPane.Showing += OnShowing;
currentInputPane.Hiding += OnHiding;
}
protected override void OnNavigatedFrom(NavigationEventArgs e)
{
InputPane currentInputPane = InputPane.GetForCurrentView();
// Unsubscribe from Showing/Hiding events
currentInputPane.Showing -= OnShowing;
currentInputPane.Hiding -= OnHiding;
}
void OnShowing(InputPane sender, InputPaneVisibilityEventArgs e)
{
//do something
}
void OnHiding(InputPane sender, InputPaneVisibilityEventArgs e)
{
//do something
}
You could also get information about the touch keyboard here: Respond to the presence of the touch keyboard
Related
I have a UserControl, empty StackPanel like following.
<Grid>
<StackPanel x:Name="datawrapper" Orientation="Horizontal" Background="Yellow"/>
</Grid>
Main window's XAML is like following.
<ScrollViewer Grid.Row="2" Grid.Column="0" Background="Gray">
<StackPanel x:Name="holderpanel" Orientation="Vertical"/>
</ScrollViewer>
I want to put datawrapper into holderpanel from the Main Window's code behind programmatically.
If there's control in the datawrapper, dadawrapper is inserted into holder panel.
However, in case of empty StackPanel, never inserted.
How to do this?
To help you clarify your question, I'll provide an example of exactly what you asked for:
<Grid>
<ScrollViewer Grid.Row="2" Grid.Column="0" Background="Gray">
<StackPanel x:Name="holderpanel" Orientation="Vertical"/>
</ScrollViewer>
<Grid>
<StackPanel x:Name="datawrapper" Orientation="Horizontal" Background="Yellow">
<TextBlock Text="Test"/>
</StackPanel>
</Grid>
</Grid>
codebehind (for this example, I added to Loaded event handler, but it could be used elsewhere):
private void MainWindow_Loaded(object sender, RoutedEventArgs e)
{
if (datawrapper.Children.Count > 0)
{
var grid = datawrapper.Parent as Grid;
grid.Children.Remove(datawrapper);
holderpanel.Children.Add(datawrapper);
}
}
The datawrapper should be separated user control and empty like following.
<Grid>
<StackPanel x:Name="datawrapper" Orientation="Horizontal" Background="Yellow"/>
</Grid>
I will add another user controls into the datawrapper horizontally 5 later. That user control is like following.
<UserControl x:Class="WpfTest.ResultItem"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:WpfTest"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid x:Name="resultitem">
<Border CornerRadius="5" BorderBrush="#e0e0e0" Background="White" BorderThickness="2" DockPanel.Dock="Top" Margin="10 10 10 15">
<Grid Margin="0 30 0 30" Background="White">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0" Grid.Column="0" Text="Chart#" Width="Auto" Height="30" Margin="5 5 0 5" FontSize="20" VerticalAlignment="Center"></TextBlock>
<TextBlock Grid.Row="1" Grid.Column="0" Text="Patient Name" Width="Auto" Height="Auto" Margin="5 5 0 5" FontSize="20" VerticalAlignment="Center"></TextBlock>
<TextBlock Grid.Row="2" Grid.Column="0" Text="Home Phone#" Width="Auto" Height="Auto" Margin="5 5 0 5" FontSize="20" VerticalAlignment="Center"></TextBlock>
<TextBlock Grid.Row="3" Grid.Column="0" Text="Cell Phone#" Width="Auto" Height="Auto" Margin="5 5 0 5" FontSize="20" VerticalAlignment="Center"></TextBlock>
<TextBlock Grid.Row="4" Grid.Column="0" Text="Patient Type" Width="Auto" Height="Auto" Margin="5 5 0 5" FontSize="20" VerticalAlignment="Center"></TextBlock>
</Grid>
</Border>
</Grid>
If the datawrapper is filled with 5 ResultItems, datawrapper will added into the holderpanel vertically.
I'm trying to put a <Border/> around a <Grid/> in a page, however the border appears to be bordering the page rather than the grid.
This is only XAML in my page element.
<Border Background="Black">
<Grid Background="{ThemeResource ControlBackgroundBrush}" x:Name="LoginCredentials" Margin="5" HorizontalAlignment="Center" VerticalAlignment="Center">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBlock TextWrapping="Wrap" Text="Username:" Style="{StaticResource SubheaderTextBlockStyle}" VerticalAlignment="Center" Grid.Row="0" HorizontalAlignment="Right" Margin="5"/>
<TextBox x:Name="UserName" TextWrapping="Wrap" HorizontalAlignment="Left" VerticalAlignment="Center" Text="" Grid.Row="0" Grid.Column="1" TextChanged="UserChange" Margin="5"/>
<Button x:Name="LoginButton" Content="Login" Click="LoginButton_Click" Grid.Row="2" HorizontalAlignment="Right" Margin="5" TabIndex="0"/>
<Button x:Name="CancelButton" Content="Cancel" Click="CancelButton_Click" Grid.Row="2" Grid.Column="1" />
</Grid>
</Border>
As a test I created a resource to fill the background of the <Grid/> with a colour and also filled the background of the <Border/> with a different colour. The <Grid/> ends up as a box in the center of the screen as intended, but the border <Border/> fills the entire screen. Can anyone tell me why this happens and how to get the <Border/> to fit around the <Grid/> as I want?
Got it!
<Border Background="Black" VerticalAlignment="Center" HorizontalAlignment="Center">
....
</Border>
As soon as i posted the question, what i was missing became clear!
I have a C# WinRT/8.1 app that uses a ListView with a child stack panel to show items in a horizontal row. That works fine, except I am having the same problem discussed in this SO post:
WinRT Xaml ListView - Touch doesn't scroll well
Except worse. My items don't scroll even when the fingertip is pressed on the margin between items. Unfortunately I don't have a parent Panorama control or ScrollView control to blame. How can I fix this?
NOTE: I switched to a ListView from a GridView because of SO posts I read that indicated GridView's with horizontal items are problematic, which was the case for me.
Here is the XAML for the page:
<Page
<!-- headers snipped for brevity -->
<Page.Resources>
<Converters:DebugBindingConverter x:Key="DebugBindingConverter"/>
<Converters:VideomarkLocationToString x:Key="VideomarkLocationToString"/>
<common:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
<DataTemplate x:Key="HorzVideomarksItemTemplate1">
<Grid d:DesignWidth="977" d:DesignHeight="746" Height="121" Width="252">
<Grid.RowDefinitions>
<RowDefinition Height="20*"/>
<RowDefinition Height="52*"/>
<RowDefinition Height="23*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<TextBlock x:Name="txtLocation" TextWrapping="Wrap" Text="{Binding OffsetSecs, Converter={StaticResource VideomarkLocationToString}}" Grid.Row="2" />
<TextBlock x:Name="txtNote" Text="{Binding Text}" TextTrimming="CharacterEllipsis"/>
<Image x:Name="imgThumbnail" Grid.Row="1" Source="{Binding ThumbnailAsync}"/>
<!-- <TextBlock x:Name="txtTest2" HorizontalAlignment="Left" Margin="81,93,0,0" TextWrapping="Wrap"
Text="{Binding Videomarks, Converter={StaticResource DebugBindingConverter}}" VerticalAlignment="Top" Height="87" Width="150" FontSize="12"/> -->
</Grid>
</DataTemplate>
</Page.Resources>
<Grid x:Name="gridPage"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" Margin="25" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="897*"/>
<ColumnDefinition Width="469*"/>
</Grid.ColumnDefinitions>
<Grid.ChildrenTransitions>
<TransitionCollection>
<EntranceThemeTransition/>
</TransitionCollection>
</Grid.ChildrenTransitions>
<Grid.RowDefinitions>
<RowDefinition Height="140"/>
<RowDefinition Height="347*"/>
<RowDefinition Height="231*"/>
</Grid.RowDefinitions>
<!-- Back button and page title -->
<Grid x:Name="gridTopRow" Grid.ColumnSpan="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="120"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Button x:Name="backButton" Margin="39,59,39,0" Command="{Binding NavigationHelper.GoBackCommand, ElementName=pageRoot}"
Style="{StaticResource NavigationBackButtonNormalStyle}"
VerticalAlignment="Top"
AutomationProperties.Name="Back"
AutomationProperties.AutomationId="BackButton"
AutomationProperties.ItemType="Navigation Button"/>
<TextBlock x:Name="pageTitle" Text="{StaticResource AppName}" Style="{StaticResource HeaderTextBlockStyle}" Grid.Column="1" TextWrapping="NoWrap" VerticalAlignment="Bottom" Margin="0,0,894,40" Tapped="pageTitle_Tapped"/>
<Button x:Name="exitButton"
Click="exitButton_Click"
Style="{StaticResource ClosePaneAppBarButtonStyle}" Margin="1065,27,0,9" Grid.Column="1" Width="100" Visibility="{Binding Main.IsDebuggerAttached, Converter={StaticResource BooleanToVisibilityConverter}, Mode=OneWay}" />
<Button x:Name="btnTest" Content="test" Grid.Column="1" HorizontalAlignment="Left" Margin="883,59,0,0" VerticalAlignment="Top" FontSize="36" Click="btnTest_Click" Visibility="Collapsed"/>
</Grid>
<WebView x:Name="webViewVideoPlayer" Grid.Row="1" ScriptNotify="ScriptNotifyPlayLocation" Margin="25" />
<Button x:Name="btnVideomark" Content="Bookmark" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="578,53,0,0" Height="54" FontSize="26.667" Click="btnVideomark_Click" Width="181"/>
<ListView
x:Name="listviewVideomarks" Grid.Row="2" Grid.ColumnSpan="2" Opacity="1" IsHitTestVisible="False" Margin="20"
ItemsSource="{Binding Videomarks.VideomarksCollection, Source={StaticResource Locator}}"
ItemTemplate="{StaticResource HorzVideomarksItemTemplate1}" SelectionMode="None"
>
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel x:Name="stackVideomarksHorz" Orientation="Horizontal">
</StackPanel>
</ItemsPanelTemplate>
</ListView.ItemsPanel>
</ListView>
<Border x:Name="borderAddVideomark" BorderThickness="5" Grid.ColumnSpan="2" Margin="369,53,319,112" Grid.Row="1" BorderBrush="#FF144989" CornerRadius="25" Opacity="0" IsHitTestVisible="False" Loaded="border_Loaded">
<Grid x:Name="gridAddVideomark" IsHitTestVisible="False" Grid.ColumnSpan="2" Grid.Row="1" Opacity="1" Grid.RowSpan="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="187*"/>
<ColumnDefinition Width="188*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="189*"/>
<RowDefinition Height="137*"/>
<RowDefinition Height="62*"/>
</Grid.RowDefinitions>
<TextBlock x:Name="lblVideomarkLocation" Grid.Column="1" TextWrapping="Wrap" Text="TextBlock" Margin="40,10,10,10" FontSize="18.667"/>
<TextBox x:Name="txtVideomarkNote" Grid.Row="1" TextWrapping="Wrap" Grid.ColumnSpan="2" Margin="10,10,10,2"/>
<Button x:Name="btnOk" Content="OK" HorizontalAlignment="Left" Margin="92,10,0,0" Grid.Row="2" VerticalAlignment="Top" Width="192" Foreground="White" FontSize="21.333" Height="45" Click="btnOk_Click"/>
<Button x:Name="btnCancel" Content="Cancel" HorizontalAlignment="Left" Margin="88,10,0,0" Grid.Row="2" VerticalAlignment="Top" Width="192" Foreground="White" FontSize="21.333" Height="45" Grid.Column="1" Click="btnCancel_Click"/>
<Rectangle x:Name="rectVideomarkThumbnail" Fill="#FFF4F4F5" Stroke="Black" Margin="10"/>
</Grid>
</Border>
</Grid>
</Page>
I am not sure which directions you are trying to scroll, but I think your problem will be fixed if you disable the StackPanel scroll and enable scrolling in both directions on the ListView.
<ListView
x:Name="listviewVideomarks" Grid.Row="2" Grid.ColumnSpan="2" Opacity="1" IsHitTestVisible="False" Margin="20"
ItemsSource="{Binding Videomarks.VideomarksCollection, Source={StaticResource Locator}}"
ItemTemplate="{StaticResource HorzVideomarksItemTemplate1}" SelectionMode="None"
ScrollViewer.HorizontalScrollMode="Auto" ScrollViewer.VerticalScrollMode="Auto"
>
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel x:Name="stackVideomarksHorz" Orientation="Horizontal"
ScrollViewer.HorizontalScrollMode="Disabled"
ScrollViewer.VerticalScrollMode="Disabled">
</StackPanel>
</ItemsPanelTemplate>
</ListView.ItemsPanel>
</ListView>
I have a big main grid with several rows and columns. I want to place in one of these cells a vertical stackpanel. In this stackpanel there is a textblock and a scrollviewer. My problem is, that the stackpanel doesn't get limited by the cell, instead the stackpanel gets big enough to fit the whole scrollviewer.
How can I solve this?
EDIT: my xaml code:
<Grid x:Name="Grid1" Margin="120,0,0,0" Width="1244">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0*"/>
<ColumnDefinition Width="33*"/>
<ColumnDefinition Width="40"/>
<ColumnDefinition Width="50*"/>
<ColumnDefinition Width="40"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="71"/>
<RowDefinition Height="40"/>
<RowDefinition/>
<RowDefinition Height="20"/>
</Grid.RowDefinitions>
<StackPanel Grid.Column="3" Grid.Row="2" Grid.ColumnSpan="2" Margin="0">
<TextBlock TextWrapping="Wrap" FontSize="48" Margin="0" VerticalAlignment="Top" Foreground="#FF0083FF" Text="Top 10:" HorizontalAlignment="Left" FontFamily="Segoe UI Light"/>
<ScrollViewer Margin="0,20,0,0" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Visible">
<StackPanel>
<ListView x:Name="TopListView" ItemsSource="{Binding}" SelectionMode="None" Foreground="White" >
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<StackPanel >
<TextBlock FontSize="32" Text="1" Foreground="#FF0083FF"/>
</StackPanel>
<TextBlock Text="{Binding Text}" Foreground="Black"
FontSize="16" Margin="0,0,0,0" TextWrapping="Wrap" />
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackPanel>
</ScrollViewer>
</StackPanel>
</Grid>
Use another Grid instead of a StackPanel:
<Grid Grid.Column="3" Grid.Row="2" Grid.ColumnSpan="2" Margin="0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition/>
</Grid.RowDefinitions>
<TextBlock FontSize="48" FontFamily="Segoe UI Light"
Foreground="#FF0083FF" HorizontalAlignment="Left"
TextWrapping="Wrap" Text="Top 10:"/>
<ScrollViewer Grid.Row="1" Margin="0,20,0,0"
HorizontalScrollBarVisibility="Disabled"
VerticalScrollBarVisibility="Visible">
...
</ScrollViewer>
</Grid >
In my Windows Store app (c#) i have Popup:
<Popup x:Name="LoginPopup" HorizontalAlignment="Center" VerticalAlignment="Center" Width="400" Height="300" IsOpen="{Binding Path=LoginPopupIsOpen}">
<Popup.ChildTransitions>
<TransitionCollection>
<PopupThemeTransition />
</TransitionCollection>
</Popup.ChildTransitions>
</Popup>
And when Popup IsOpen I need handle events only on Popup and freeze all another UI (including AppBar). It is possible without creating full screen popup with little work area?
You can do it in the xaml.cs file by using two properties.
In the event handler for the popup you are creating you can include the following two lines
this.IsEnabled = false;
this.ApplicationBar.IsVisible = false;
in the event handler where you want to close the popup, you can revert the properties back to their original values.
this.IsEnabled = true;
this.ApplicationBar.IsVisible = true;
I was also facing similar problem and used this to handle that.
private void AlertMessage_Opened(object sender, object e)
{
UIBlock.Visibility = Windows.UI.Xaml.Visibility.Visible;
}
private void AlertMessage_Closed(object sender, object e)
{
UIBlock.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
}
My popup name was AlertMessage and I attack opened and closed events with it and place a border in xaml which covers whole screen, and handle is visibility through these events.
<Border Name="UIBlock" Grid.Row="0" Grid.RowSpan="3" Background="#AAFFFFFF" Visibility="Collapsed">
</Border>
And remember to place this border before popup
I have made small popup using below code.Please try this.
<Grid Background="Black" Opacity="0.7" Visibility="Collapsed" x:Name="gdalert" Height="{Binding Height, ElementName=gdfullpage}" Width="{Binding Width, ElementName=gdfullpage}">
<Popup x:Name="settingpopup" Width="350" Grid.Row="1" HorizontalAlignment="Center" VerticalAlignment="Center">
<Border x:Name="settingbdrmain" Grid.Row="1" BorderThickness="0" Width="350" CornerRadius="15" >
<Grid x:Name="gdsubshape" Margin="0,10,0,10">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
</Grid.RowDefinitions>
<TextBlock Margin="0,0,0,0" Grid.Row="0" x:Name="dddf" FontSize="20" Text="" HorizontalAlignment="Center" TextAlignment="Center" FontFamily="Arial" FontWeight="Bold" TextWrapping="Wrap" ></TextBlock>
<TextBlock x:Name="txtsettingalert" Text="" FontSize="20" TextAlignment="Center" Width="300" FontFamily="Arial" TextWrapping="Wrap" Foreground="Black" Grid.Row="1" ></TextBlock>
<Border x:Name="settingbdr" Width="350" Grid.Row="2" Height="1" Background="Red" BorderBrush="Black" >
</Border>
<Grid x:Name="btnpanel" Grid.Row="3" Height="60">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"></ColumnDefinition>
<ColumnDefinition Width="Auto"></ColumnDefinition>
<ColumnDefinition Width="Auto">/ColumnDefinition>
</Grid.ColumnDefinitions>
<Button x:Name="settingok" Grid.Column="0" Height="50" HorizontalAlignment="Left"VerticalAlignment="Center" MinHeight="20" Width="170" Content="OK" FontSize="24" Foreground="Green" ></Button>
<Border x:Name="settingsubbdr" Grid.Column="1" BorderBrush="Green" Height="Auto" Width="1" ></Border>
<Button x:Name="sl" Grid.Column="2" Height="50" HorizontalAlignment="Right" VerticalAlignment="Center" MinHeight="20" Width="170" Content="Cancel" FontSize="24" Foreground="Green" ></Button>
</Grid>
</Grid>
</Border>
</Popup>
To Open Use :- popname.IsOpen = true; gdalert.Visibility = Visibility.Visible;
To Close popname.IsOpen = false; gdalert.Visibility = Visibility.Collapse;