我有带有自定义用户控件的gridview。这是用户控件的 XAML:
<UserControl
x:Class="App11.VideoPreview"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:App11"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="250"
d:DesignWidth="250">
<Grid>
<Button Height="250" Width="250" Padding="0" BorderThickness="0">
<StackPanel>
<Image Name="image1" Height="250" Width="250" Stretch="None"/>
<Grid Margin="0,-74,0,0">
<Grid.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0" Opacity="0.5">
<GradientStop Color="Black"/>
<GradientStop Color="#FF5B5B5B" Offset="1"/>
</LinearGradientBrush>
</Grid.Background>
<TextBlock x:Name="textBox1" TextWrapping="Wrap" FlowDirection="RightToLeft" Foreground="White" Padding="5"/>
</Grid>
</StackPanel>
</Button>
</Grid>
</UserControl>
在gridview中单击按钮时如何捕获单击事件?我试过了GridView_ItemClick
,GridView1_SelectionChanged
在gridview页面的.cs中,我也在button_Click
usercontrol页面的.cs中试过,
两者都对我不起作用。知道为什么吗?
编辑:它确实有效。我只是尝试使用Frame.Navigate(typeof(PageName));
I cant change frame from usercontrol 来更改框架,我必须在构建函数中将当前框架发送到 usercontrol,然后更改框架,如下所示:
Frame frame;
public VideoPreview(Frame f)
{
this.InitializeComponent();
frame = f;
}
private void Button_Click(object sender, RoutedEventArgs e)
{
frame.Navigate(typeof(PlayVideo));
}