我想定义类似这样的内容
<myCustomControl>
<myCustomControl.Images>
<Image
Source="{StaticResource LockedIcon16}" />
<Image
Source="{StaticResource UnlockedIcon16}"/>
<myCustomControl.Images>
<myCustomControl/>
我需要使用哪些属性定义才能获得该集合(图像)?
答案 0 :(得分:1)
System.Windows.Controls.Image
应该这样做。
没有测试过,但它应该可以工作。
public class myCustomControl {
//...
public ObservableCollection<Image> Images {
get { return (ObservableCollection<Image>)GetValue(ImagesProperty); }
set { SetValue(ImagesProperty, value); }
}
// Using a DependencyProperty as the backing store for Images. This enables animation, styling, binding, etc...
public static readonly DependencyProperty ImagesProperty =
DependencyProperty.Register("Images", typeof(ObservableCollection<Image>), typeof(myCustomControl), new PropertyMetadata(null));
}