Dec*_*oon 6 xaml windows-phone-8.1
Windows Phone 8.1为对话框和弹出窗口引入了一个新的过渡,看起来像一个百叶窗.我不喜欢这个; 我更喜欢它在Windows Phone 8中的样子,它可以旋转/倾斜.有没有办法改变这个?
我尝试过这样的事情:
<ContentDialog.Transitions>
<TransitionCollection>
</TransitionCollection>
</ContentDialog.Transitions>
Run Code Online (Sandbox Code Playgroud)
但它并没有改变过渡.
您不能覆盖ContentDialog等中的过渡。它们被设计为获得标准行为的简便方法,并且将始终使用PopupThemeTransition。
如果您想要非标准行为,则可以编写一个使用您自己的TransitionCollection的自定义控件。我找不到与此相关的任何现有示例,但请查看Callisto的CustomDialog中的一般概念。它模仿Windows MessageDialog,其内容位于全屏调光窗口上方水平居中的栏中,但不难改变UI以匹配Windows Phone的顶级面板。
一旦掌握了自己的控制权,就可以使用任何您喜欢的转换。我没有方便的WP8设备来查看转换是什么,但是带有Edge =“ Left”的PaneThemeTransition听起来像它符合您的描述。如果没有,那么一旦进行了转场,就可以将其交换为自己喜欢的转场,或者删除所有转场并应用自己的情节提要动画。我要么坚持对用户有意义的标准过渡,要么进行完全自定义,因为主题过渡可能会再次发生变化。
创建一个看起来正确的面板非常容易。棘手的部分是如何显示控件。如果将其包含在Xaml中,那么它就成为可视化树的一部分,然后就可以显示它。如果它不在可视树中,则需要将其添加到可视树中或将其托管在弹出窗口中。
这是一个快速而肮脏的UserControl,它在弹出窗口中托管自己,并使用PaneThemeTransition从右侧滑入。
<UserControl
x:Class="App199.MyUserControl1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:App199"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="300"
d:DesignWidth="400"
PointerReleased="UserControl_PointerReleased">
<UserControl.Transitions>
<TransitionCollection>
<PaneThemeTransition Edge="Left"/>
</TransitionCollection>
</UserControl.Transitions>
<Grid>
<Grid.RowDefinitions>
<RowDefinition x:Name="statusBarRow" Height="0" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackPanel Grid.Row ="1" Background="Black">
<Ellipse Height="100" Width="100" Fill="Yellow" />
<TextBlock>Lorem Ipsum</TextBlock>
<Rectangle Height="100" Width="100" Fill="Red" />
</StackPanel>
<Border Grid.Row="2" Background="#7F000000" />
</Grid>
Run Code Online (Sandbox Code Playgroud)
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.Phone.UI.Input;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
// The User Control item template is documented at http://go.microsoft.com/fwlink/?LinkId=234236
namespace App199
{
public sealed partial class MyUserControl1 : UserControl
{
Popup hostPopup;
public MyUserControl1()
{
this.InitializeComponent();
hostPopup = new Popup();
hostPopup.Child = this;
Loaded += MyUserControl1_Loaded;
Unloaded += MyUserControl1_Unloaded;
}
void MyUserControl1_Loaded(object sender, RoutedEventArgs e)
{
HardwareButtons.BackPressed += HardwareButtons_BackPressed;
}
void MyUserControl1_Unloaded(object sender, RoutedEventArgs e)
{
HardwareButtons.BackPressed -= HardwareButtons_BackPressed;
}
public void Show()
{
this.Height = Window.Current.Bounds.Height;
this.Width = Window.Current.Bounds.Width;
var occRect = Windows.UI.ViewManagement.StatusBar.GetForCurrentView().OccludedRect;
statusBarRow.Height = new GridLength(occRect.Height);
hostPopup.IsOpen = true;
}
void HardwareButtons_BackPressed(object sender, BackPressedEventArgs e)
{
if (hostPopup.IsOpen)
{
hostPopup.IsOpen = false;
e.Handled = true;
}
}
private void UserControl_PointerReleased(object sender, PointerRoutedEventArgs e)
{
hostPopup.IsOpen = false;
}
}
}
Run Code Online (Sandbox Code Playgroud)