[英]UWP Grid Transitions
I tried to create a transition for my pop up grid (usercontrol). 我试图为我的弹出网格(用户控件)创建一个过渡。 It work well, but just once, after that, the transition doesn't work, furthermore, I havn't the reverse transition when I close my grid 它运作良好,但仅此一次,此后过渡就不起作用,而且,当我关闭网格时,我没有进行反向过渡
Xaml UserControl: Xaml UserControl:
<UserControl Visibility="Collapsed">
<Grid Background="red">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.Transitions>
<TransitionCollection>
<EdgeUIThemeTransition Edge="Bottom"/>
</TransitionCollection>
</Grid.Transitions>
<StackPanel>
<Button Content="Close" Click="close_Click"/>
</StackPanel>
</Grid>
</UserControl>
C# UserControl: C#UserControl:
public sealed partial class MyUserControl1 : UserControl
{
public MyUserControl1()
{
this.InitializeComponent();
}
private void close_Click(object sender, RoutedEventArgs e)
{
Visibility = Visibility.Collapsed;
}
}
Xaml Page: Xaml页面:
<Page>
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<local:MyUserControl1 x:Name="popUp"/>
<Button Content="Open" Click="Open_Click"/>
</Grid>
</Page>
C# Page: C#页面:
private void Open_Click(object sender, RoutedEventArgs e)
{
popUp.Visibility = Visibility.Visible;
}
i think the probleme is Visibility, but i need it to show and hide my control, should i use visual state in my usercontrol ? 我认为问题是可见性,但是我需要它来显示和隐藏控件,我应该在用户控件中使用视觉状态吗?
In the click_Close statement have you tried using 在click_Close语句中您是否尝试过使用
this.Visibility = Visibility.Collapsed;
because the way I am reading it, there doesn't seem to be a targeted element right now. 因为按照我的阅读方式,目前似乎没有针对性的元素。
I admit, I have not tested this - it is just something I noticed and hopefully it works and saves you some coding. 我承认,我还没有测试过-这只是我注意到的东西,希望它可以工作并为您节省一些编码。 (I know just enough C# to be dangerous >=D ) (我知道C#足以使危险> = D)
Now i use: 现在我使用:
C# UserControl(delete the usercontrol): C#UserControl(删除用户控件):
private void close_Click(object send, RoutedEventArg e)
{
((Panel)this.Parent).Children.Remove(this);
}
Xaml UserControl(i set the transition here) Xaml UserControl(我在这里设置过渡)
<UserControl.Transitions>
<TransitionCollection>
<EdgeUIThemeTransition Edge="Botom"/>
</TransitionCollection>
</UserControl.Transitions>
c# page(create an user control): C#页面(创建用户控件):
MyUserControl cont = new MyUserControl();
MygridName.children.Add(cont);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.