私が作成した WPF アプリケーションには、3 行のグリッドが含まれています。3行目にボタンのセットがあります。ボタンをクリックすると、フォームがグリッドの 2 行目に表示されます。ただし、すべてのフォーム コンテンツを同じウィンドウで作成し、可視性を非表示に設定しているため、私が行ったことは非常に面倒です。
サンプルコード:
<Grid Name="panel1" Grid.Row="1" Visibility="Hidden">
//contains a lot of textblocks,buttons and images
</Grid>
<Grid Name="panel2" Grid.Row="1" Visibility="Hidden">
//contains a lot of textblocks,buttons and images
</Grid>
<Grid Name="panel3" Grid.Row="1" Visibility="Hidden">
//contains a lot of textblocks,buttons and images
</Grid>
私のxamlコードは次のようになります:
private void Image_MouseLeftButtonDown_1(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
panel1.Visibility = System.Windows.Visibility.Hidden;
panel2.Visibility = System.Windows.Visibility.Visible;
panel3.Visibility = System.Windows.Visibility.Hidden;
}
メイン Xaml ファイルにすべてのコードを含めたので、このアプローチは非常に面倒に見えます。これを行うには、いくつかの代替方法が必要です。親切に助けてください。