私はC#でWumpus Worldを作成しようとしています。更新UI UWPページアプリケーション
MainPage.xamlを
<Page
x:Class="MundoWumpus.SecondPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:MundoWumpus"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" Padding="10">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock Text="Mundo de Wumpus" FontSize="30" HorizontalAlignment="Center" VerticalAlignment="Bottom" Margin="0,10" />
<ContentControl x:Name="myContent" HorizontalAlignment="Center" Grid.Row="1"/>
</Grid>
SecondPage.cs
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.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;
// O modelo do item de página em branco está documentado em http://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409
namespace MundoWumpus
{
/// <summary>
/// Uma página vazia que pode ser usada isoladamente ou navegada dentro de um Quadro.
/// </summary>
public sealed partial class SecondPage : Page
{
public SecondPage()
{
this.InitializeComponent();
}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
int size = (int)e.Parameter();
World world = new World(size);
WorldCanvas wrldCanvas = new WorldCanvas(size);
myContent.Content = WrldCanvas;
}
}
}
CanvasWorldキャンバスから派生するクラスです: これらは、いくつかのクラスです。 MainPageから受け取ったパラメータ(サイズ)が必要なのでSecondPageで初期化する必要があります。 CanvasWorld(size)は、正方形の等級を作るメソッドコンストラクタです。 SecondaryPageを更新する方法を知りたいのですが、wrldCanvasは初期化されてページに表示されますが、配置されていないためです。
観測のおかげで。しかし、それは保護されています。私はちょうど間違って書いた! –
@SérgioDamasceno、このメソッドのパラメータは 'EventArgs e'ではなく' NavigationEventArgs e'であることに注意してください。 –