ユーザーは、ユーザーが動的にUIを定義できるようにXamlReaderを使用しています。ユーザー定義コードを使用したXamlReaderの動的イベント
たとえば、複数のボタンでグリッドを定義したい場合は、xaml stringを定義して行うことができます。
var xaml = `
<Grid xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' Height='600' Background='Gray'>
<Grid.ColumnDefinitions>
<ColumnDefinition Width='2*' />
<ColumnDefinition Width='1*' />
<ColumnDefinition Width='1*' />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height='2*' />
<RowDefinition Height='1*' />
<RowDefinition Height='1*' />
</Grid.RowDefinitions>
<TextBlock Name='FirstName' xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' Text='TESTING' Grid.Row='0' Grid.Column='0' Height='20' />
<TextBox Name='LastName' xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' Text='TESTING' Grid.Row='1' Grid.Column='0' Height='20' />
<Button Grid.Column='1'>Button 2</Button>
<Button Grid.Column='2'>Button 3</Button>
<Button Grid.Column='1' Grid.Row='1'>Button 5</Button>
<Button Grid.Column='2' Grid.Row='1'>Button 6</Button>
<Button Grid.Row='2'>Button 7</Button>
<Button Grid.Column='1' Grid.Row='2'>Button 8</Button>
<Button Grid.Column='2' Grid.Row='2'>Button 9</Button>
</Grid>
`;
var control = Windows.UI.Xaml.Markup.XamlReader.Load(xaml) as UIElement;
はしかし、我々はまた、ユーザーがイベントを定義できるようにしたいです。たとえば、ボタン1をクリックすると、メッセージボックスが表示されます。ボタン2をクリックすると、他の操作が実行されます。
XamlReader.Loadと同様に、コード自体を指定できるようにします。
これを行う方法はありますか?