是这样的,我先放了一个Wrappanel,想用代码在里面添加一个Button,此Button带有模版
<ControlTemplate x:Key="ImageButton" TargetType="Button"> <Grid> <Image Source="{TemplateBinding Content}" Stretch="Fill" /> <StackPanel x:Name="stackPanel" Height="30" VerticalAlignment="Bottom" RenderTransformOrigin="0.5,0.5"> <StackPanel.RenderTransform> <CompositeTransform/> </StackPanel.RenderTransform> <TextBlock TextWrapping="Wrap" Text="{TemplateBinding Tag}" FontSize="24" HorizontalAlignment="Center"/> </StackPanel> </Grid> </ControlTemplate>
我是这样写的
wrap1.Children.Add(new Button() { Content = "", Template = { } });
不知道括号里怎么写
求高手帮忙