Canvas问题
<Canvas x:Name="a1">
<StackPanel Orientation="Vertical" HorizontalAlignment="Center" Margin="10">
<StackPanel Orientation="Horizontal">
<TextBlock Text="aa: " />
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="bb: " />
</StackPanel>
</StackPanel>
</Canvas>
<Canvas x:Name="a2">
</Canvas>
请问:怎样将a1的内容直接加到a2上
[解决办法]
方法1: 创建Usercontrol,将Canvas2放在Usercontrol中,Canvas1进行调用.<local:xxx></local:xxx>
方法2: 动态载入,将Canvas2作为Children添加到Canvas1中。
canvas1.Children.add(Canvas2)
[解决办法]
楼上思路 正解
[解决办法]
<Grid> <Grid.RowDefinitions> <RowDefinition/> <RowDefinition Height="40"/> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition/> <ColumnDefinition/> </Grid.ColumnDefinitions> <Canvas x:Name="a1"> <StackPanel Orientation="Vertical" HorizontalAlignment="Center" Margin="10"> <StackPanel Orientation="Horizontal"> <TextBlock Text="aa: " /> </StackPanel> <StackPanel Orientation="Horizontal"> <TextBlock Text="bb: " /> </StackPanel> </StackPanel> </Canvas> <Canvas x:Name="a2" Grid.Column="1"> </Canvas> <Button x:Name="Clone" Click="Clone_Click" Margin="10,6,10,6" Grid.Row="1" Content="Clone"/> <Button x:Name="Add" Click="Add_Click" Margin="10,6,10,6" Grid.Row="1" Grid.Column="1" Content="Add Control"/> </Grid>
[解决办法]
推荐方法1: 创建Usercontrol,将Canvas2放在Usercontrol中,Canvas1进行调用.<local:xxx></local:xxx>
自定义用户控件以重用