문제

I want to define something like this

<myCustomControl>
  <myCustomControl.Images>
     <Image
        Source="{StaticResource LockedIcon16}" />
     <Image
        Source="{StaticResource UnlockedIcon16}"/>
  <myCustomControl.Images>
<myCustomControl/>

what property definitions do i need to get that collection (Images) happening?

도움이 되었습니까?

해결책

System.Windows.Controls.Image should do it.

Haven't tested it, but it should work.

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));
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top