我不知道如何开始,所以我只是从截图和它的代码开始:
主页.xaml
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="48"/>
</Grid.RowDefinitions>
<Frame x:Name="MainContent"/>
<Grid Grid.Row="1" Background="Gray">
<TextBlock x:Name="ResultTB"
VerticalAlignment="Center"
Text="Should also be here"
HorizontalAlignment="Center"/>
</Grid>
</Grid>
MainPage.xaml.cs
public MainPage()
{
InitializeComponent();
MainContent.Navigate(typeof(ContentFrame));
}
ContentFrame.xaml
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<TextBox x:Name="Input"
VerticalAlignment="Center"
HorizontalAlignment="Center"
Width="200"/>
</Grid>
现在我想对 ResultTB 的输入文本进行渐变。最简单、最好的方法是什么?
最佳答案
对于将来寻找这个的任何人 - 与 Alexej 有点相似但更简单的答案: 例如,假设我想更改位于 MainPage 中的对象“SomeObject”(x:Name = “SomeObject”) 的文本:
MainPage mainFrame = (MainPage)((Frame)Window.Current.Content).Content;
mainFrame.SomeObject = "my text";
关于c# - 如何在 UWP 中获取另一个页面的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37088433/