Domanda

voglio definire qualcosa di simile

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

quale proprietà definizioni fare ho bisogno di ottenere che la raccolta (Immagini) succedendo?

È stato utile?

Soluzione

System.Windows.Controls.Image dovrebbe farlo.

non hanno testato, ma dovrebbe funzionare.

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));
}
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top