locked
Blend doesn't recognize dependency property of element inherited from MediaElement, when this element is placed inside DataTemplate/ControlTemplate RRS feed

  • Question

  • I created a control that inherits from standard wpf MediaElement and added in this control new DependencyProperty

    amespace TestControlInheritance
    {
      public class InheritedMedia : MediaElement
      {
        static InheritedMedia()
        {
          DefaultStyleKeyProperty.OverrideMetadata(typeof(InheritedMedia), new FrameworkPropertyMetadata(typeof(InheritedMedia)));
        }
    
        public static readonly DependencyProperty IntTestProperty = DependencyProperty.Register("IntTest", typeof(int), typeof(InheritedMedia));
    
        public int IntTest
        {
          get
          {
            return (int)this.GetValue(IntTestProperty);
          }
          set
          {
            this.SetValue(IntTestProperty, value);
          }
        }
    
        public static readonly DependencyProperty FileSourceProperty =
        DependencyProperty.Register("FileSource", typeof(string),
        typeof(InheritedMedia),
        new PropertyMetadata(new PropertyChangedCallback(OnFileSourcePropertyChanged)));
    
        public string FileSource
        {
          get
          {
            return (string)GetValue(FileSourceProperty);
          }
          set
          {
            SetValue(FileSourceProperty, value);
          }
        }
    
        private static void OnFileSourcePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs arg)
        {
          string src = (string)arg.NewValue;
          InheritedMedia vid = (InheritedMedia)d;
        }
    
    
      }
    }

    When I put this control just inside Window it works fine and new dependensy properties are recognized by Blend. But when I put this control inside DataTemplate/ControlTemplate like this

    <local:InheritedMedia x:Name="InheritedMedia1" Margin="10,10,0,0" Width="200" Height="100" HorizontalAlignment="Left" VerticalAlignment="Top" Source="main_kupons_nosound.avi" FileSource="aaa" IntTest="5"/>

    I receive error  “’InheritedMedia.FileSource’ attached property is not defined on ‘MediaElementInstance’ or one of its based classes."

    Project compiled good and code can interact with new Dependency Property, but there is no Blend support for template having this control inside.

    If I create control inheriting from Image or Canvas, there are not such problems at all.

    Is it possible to avoid this behavior?

    Elena

     

     

     
     
    Wednesday, April 28, 2010 4:57 PM

All replies

  • Hi Elena,

    Are you using Blend 3?

    Can you please try this with Blend 4 RC? To me it looks like this scenario is working in there.

    Thanks,
    Unni


    This posting is provided "AS IS" with no warranties, and confers no rights.
    Wednesday, April 28, 2010 5:56 PM
  • Thank you, it works in Blend4.  The only problem remained is the Blend4 demands Framework4 installed on computer, but just now we have development on Framework3.5. Is it possible to do something for framework 3.5?

    Thanks,

    Elena

    Thursday, April 29, 2010 10:28 AM