【发布时间】:2015-11-03 06:29:29
【问题描述】:
我有一个我的 Windows Phone 8 应用程序页面。该页面有一个根网格,其中有一个 Grid 元素,其中包含页面的正常控件。根网格中还有一个用户控件。 Grid 和 usercontrol 都在根网格中的 0,0 中。现在的问题是,当我让用户控件可见并使用它来显示一些“请稍候”信息时,包含应用程序所有正常控件的另一个网格仍然会获得触摸输入。
整个想法是,冗长的操作会导致用户控件显示为半透明背景和一条消息,请稍候。我想以某种方式将其设置为捕获所有输入,但没有任何效果。
这是用户控件:
<UserControl x:Class="UserControls.ProgressPopup" ...>
<Grid Name="ContentArea" MinWidth="200" MinHeight="200"
HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
Margin="0" ManipulationStarted="ContentArea_ManipulationStarted"
Tap="ContentArea_Tap"
MouseLeftButtonDown="ContentArea_MouseLeftButtonDown">
<Rectangle Opacity="0.85" Name="TheBackground"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Fill="{StaticResource PhoneBackgroundBrush}"/>
<ProgressBar Background="Transparent" Opacity="1" x:Name="ProgressBar"
IsIndeterminate="{Binding bIsIndeterminate}"
HorizontalAlignment="Stretch" Width="auto"
Height="12" Margin="0,-30,0,0"/>
<TextBlock ... />
</Grid>
</UserControl>
这是它在页面上的使用方式:
<phone:PhoneApplicationPage
x:Class="AirMobility.Pages.MainPage"
... >
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid Background="Transparent" Margin="0" x:Name="PageStuff">
...
</Grid>
<usercontrols:ProgressPopup Grid.Row="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" x:Name="WaitScreen" Visibility="Collapsed" Background="Transparent"/>
</Grid>
</phone:PhoneApplicationPage>
当名为“WaitScreen”的用户控件变为可见时,“PageStuff”网格和其中的控件仍会获得输入。该网格内部是一个枢轴控件,并且枢轴控件的页面仍然可以滚动。我试图获取 ManipulationStarted 事件并设置 e.handler=true 以停止传播,但它不起作用。似乎没有任何效果。
关于如何在用户控件或页面 xaml 中的用户控件定义中处理此问题的任何想法?我只是不想以某种方式在每个具有这些“WaitScreen”用户控件之一的页面上添加一堆事件处理程序。
[编辑...]
我尝试了用户控件的这种变体,但仍然无法正常工作:
<UserControl x:Class="UserControls.ProgressPopup"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
FontFamily="{StaticResource PhoneFontFamilyNormal}" FontSize="{StaticResource PhoneFontSizeLarge}">
<Grid Name="ContentArea" MinWidth="200" MinHeight="200" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="0" Background="#01808080">
<Grid Name="TheBackground" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="#80204080"/>
<ProgressBar Background="Transparent" Opacity="1" x:Name="ProgressBar"
IsIndeterminate="{Binding bIsIndeterminate}" HorizontalAlignment="Stretch" Width="auto" Height="12" Margin="0,-30,0,0"/>
<TextBlock Name="textBlock" Foreground="{StaticResource PhoneForegroundBrush}" Text="{Binding Text}" MinWidth="200" TextAlignment="Center"
Opacity="1" Margin="0,14,0,0" VerticalAlignment="Center" HorizontalAlignment="Stretch" Height="40" FontSize="{Binding Source={StaticResource PhoneFontSizeNormal}}" FontFamily="{Binding Source={StaticResource PhoneFontFamilyNormal}}" />
</Grid>
</UserControl>
底层枢轴仍然可以移动。
【问题讨论】:
-
添加点击事件处理程序后,看起来点击没有通过。剩下的唯一症状就是usercontrol下的pivot控件仍然可以拖动/滑动来换页。
标签: c# xaml silverlight windows-phone-8 user-controls