Hai. I have a XAML page and a c # control code. There is a block in this page, its contents may change depending on the events, that is, it is necessary to insert XAML code into this block (it can be written both in a separate file (the best option) and in string), which must also be hung managed C # code. Tell me how to implement it. Thank.
eg
namespace App5{ public sealed partial class Content : Page { public Content() { this.InitializeComponent(); } private void Click(object sender, RoutedEventArgs e) { //do } }}
Xaml:
<Page x:Class="App5.Content" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:App5" 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}"> <Button Content="BUTTON" Click="Click"/> </Grid> </Page>
I need to insert this page into the block. StackPanel Name = "DataPage"
<Page x:Class="App5.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:App5" 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}"> <StackPanel Name="DataPage"/> </Grid> </Page>
For any event that occurred on MainPage, everything that contains the content page must be inserted into the <StackPanel Name="DataPage"/>
block. In this example, a GRID with a button is inserted. It is necessary not only to insert the content, but also to save the click event hung on the button.
If someone is familiar, it is like dynamic loading of pages on ajax (web), when there are static elements on the page (menu, header, footer), but there is a part that is constantly updated (usually this is the page content itself) when clicking on a link or other events.
UserControl
. But yes, better describe your particular case. Now your question is too general. - VladDContent
page. This second page is shown separately, right? And there is a button on it, by pressing which the contents of this second page should go to the main page? - VladD