XAML 如何从其他帧(第二帧)折叠对象(第一帧)WUA

8wigbo56  于 2022-12-07  发布在  其他
关注(0)|答案(1)|浏览(83)

我有一个简单的问题(希望如此)。我需要从其他窗体/框架(子或父)折叠(或做一些其他更改)到窗体/框架中的对象,但我不知道如何做。值得一提的是,我正在开发Windows通用应用程序。我还需要从其他框架加载框架到其他框架...
我想让它变得非常简单,容易让你们理解,这就是为什么我想展示一个非常简单的例子,我的意思。
对不起,我的英语,不是我的母语。
第一页XAML

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"></RowDefinition>
        <RowDefinition Height="Auto"></RowDefinition>
        <RowDefinition Height="Auto"></RowDefinition>
    </Grid.RowDefinitions>
    <StackPanel Grid.Row="0">
        <Button Content="LoadFrame" Click="Button_Click"/>
        <Button x:Name="KillMeOne" Content="Kill Me From Frame Two"/>
    </StackPanel>
    <Frame x:Name="TheSecondFrame" Grid.Row="1"/>
    <Frame x:Name="FrameThreeComesHere" Grid.Row="2"/>
</Grid>

第二页XAML

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
    <StackPanel>
        <Button Content="Load Frame Three From Here Form In 'FrameThreeComesHere-frame' But How?"/>
        <Button Content="Kill The Button From Page One But How?"/>
    </StackPanel>
</Grid>

第三页XAML

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
    <TextBlock Text="HelloWord!"/>
</Grid>

第一页CS代码...

private void Button_Click(object sender, RoutedEventArgs e)
    {
        TheSecondFrame.Navigate(typeof(PageTwo));
    }
ruarlubt

ruarlubt1#

为第1页创建一个数据上下文,将要隐藏的元素的可见性绑定到数据上下文的属性。然后从第2页获取第1页的数据上下文,更改属性以更改第1页上元素的可见性。

相关问题