08/09/18 07:16:37
>>411,418
Childrenコレクションに子要素を追加すればHTML DOMと同じようなことが出来る。
>>207のを参考に。これのやってることは次のXAMLとかわらん。
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="84"/>
</Grid.RowDefinitions>
<DockPanel x:Name="DockPanel1" Grid.Row="0">
<TextBlock x:Name="tb1" TextWrapping="Wrap" Background="Aqua">not used xaml wpf-application demo</TextBlock>
<TextBlock x:Name="dynatb" TextWrapping="Wrap" Background="Yellow">いろはにほへと ちりぬるを</TextBlock>
<TextBlock x:Name="tb3" TextWrapping="Wrap" Background="LightBlue">
いろはにほへと ちりぬるを いろはにほへと ちりぬるを いろはにほへと ちりぬるを いろはにほへと ちりぬるを いろはにほへ..
</TextBlock>
</DockPanel>
<Button x:Name="Button1" Grid.Row="1" Height="48" Width="240" Content="push me" FontSize="24"/>
</Grid>
例えば、ボタンをDockPanelに動的に追加したいなら
DockPanel1.Children.Add(new Button()) といった感じになる。