Wpf 当列表处于';它是用XAML创建的
所以,我用xaml做了一个控件Wpf 当列表处于';它是用XAML创建的,wpf,xaml,Wpf,Xaml,所以,我用xaml做了一个控件 <Button x:Name="cancelOptionButton" HorizontalAlignment="Left" VerticalAlignment="Top" Width="15" Height="15" Style="{DynamicResource ButtonStyle1}" BorderBrush="Black" Foreground="Black" Margin="3,3,0,0" Click="opt
<Button x:Name="cancelOptionButton" HorizontalAlignment="Left" VerticalAlignment="Top" Width="15" Height="15"
Style="{DynamicResource ButtonStyle1}" BorderBrush="Black" Foreground="Black" Margin="3,3,0,0" Click="optionsButton_Click_1">
<Button.Background>
<ImageBrush ImageSource="Cancel_Icon.png" />
</Button.Background>
</Button>
但是在我创建控件的xaml中,有没有办法做到这一点
我不是在谷歌搜索错误的东西,就是问的问题很荒谬:)
但是在我创建控件的xaml中,有没有办法做到这一点
不,如果不首先获取对该字段的引用并以编程方式对其调用add
,则无法将在XAML标记中创建的控件添加到列表字段
XAML是一种标记语言。它不应该像编程语言那样使用
您可以将一个控件添加到另一个控件的集合依赖项属性中,但这是另一回事。感谢mate的快速回答。所以这毕竟是荒谬的。
private List<Control> controlList = new List<Control>();
controlList.Add(cancelOptionButton);