Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 7th, 2012  |  syntax: None  |  size: 0.96 KB  |  hits: 11  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. UserControl with List<T> property - any chance for declarative definition?
  2. public List<Rect> HotSpots
  3. {
  4.    get { return (List<Rect>)GetValue(HotSpotsProperty); }
  5.    set { SetValue(HotSpotsProperty, value); }
  6. }
  7.  
  8. public static readonly DependencyProperty HotSpotsProperty =
  9.         DependencyProperty.Register("HotSpots", typeof(List<Rect>), typeof(ImageViewPort), new FrameworkPropertyMetadata(HotSpotsChanged));
  10.        
  11. <WPF:ImageViewPort Grid.Row="1">
  12.    <WPF:ImageViewPort.HotSpots>
  13.       <Rect Location="0,0" Height="30" Width="50"></Rect>
  14.        <Rect Location="10,35" Height="30" Width="20"></Rect>
  15.    </WPF:ImageViewPort.HotSpots>
  16.  </WPF:ImageViewPort>
  17.        
  18. <WPF:ImageViewPort Grid.Row="1" HotSpots="{Binding Path=HotSpots}"/>
  19.        
  20. public class HotSpotList : List<Rect> {}
  21.        
  22. <WPF:ImageViewPort.HotSpots>
  23.   <HotSpotList>
  24.    <Rect Location="0,0" Height="30" Width="50"></Rect>
  25.    <Rect Location="10,35" Height="30" Width="20"></Rect>
  26.   </HotSpotList>
  27. </WPF:ImageViewPort.HotSpots>