2015-11-09 1 views
0

Я конвертирую код из Silverlight в WPF, но я хочу, чтобы приложение впоследствии работало в обоих. Поэтому я связываю файлы silverlight с новыми проектами wpf. Я получаю эту ошибку, когда я преобразовать его в проект WPF:Не удается найти статический член «ThumbnailSourceProperty» в типе «CcsThumbnailDisplay»

Ошибка 1 Не удается найти статический член «ThumbnailSourceProperty» на «CcsThumbnailDisplay» типа. C: \ Users \ sahluwai \ Desktop \ cusControls2 \ Leitch \ HarrisSilverlightToolkit \ Toolkit \ Source \ Controls \ DisplayControls \ Streaming \ Themes \ CcsThumbnailDisplay.xaml 22 109 DisplayControls

мой XAML код:

<ResourceDictionary 
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
xmlns:local="clr-namespace:Harris.BCD.Toolkit.Silverlight.Controls"> 

<Style TargetType="local:CcsThumbnailDisplay"> 
    <Setter Property="MinWidth" Value="40" /> 
    <Setter Property="MinHeight" Value="30" /> 
    <Setter Property="Background" Value="#FF000000"/> 
    <Setter Property="Template"> 
     <Setter.Value> 
      <ControlTemplate TargetType="local:CcsThumbnailDisplay"> 
       <Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch"> 
        <Grid.RowDefinitions> 
         <RowDefinition Height="*"/> 
         <RowDefinition Height="Auto"/> 
        </Grid.RowDefinitions> 
        <Border BorderBrush="#FF3C3C3C" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" 
          BorderThickness="8" 
          Padding="0" 
          Grid.Row="0"> 


///////////////////////////////error line////////////////////////////////////// 
//i am getting the error in this line below: 

         <Image HorizontalAlignment="Stretch" Source="{TemplateBinding ThumbnailSource}" Stretch="Uniform"/> 


        </Border> 
        <Border BorderBrush="#FF3C3C3C" 
          BorderThickness="1" 
          Padding="0" 
          Grid.Row="1"> 
         <TextBlock Text="{TemplateBinding ChannelLabel}" 
            Foreground="White" 
            TextAlignment="Center"/> 
        </Border> 
       </Grid> 
      </ControlTemplate> 
     </Setter.Value> 
    </Setter> 
</Style> 

мой код позади файла:

namespace Harris.BCD.Toolkit.Silverlight.Controls 
{ 
/// <summary> 
///  Control: Video Image Display 
///  
///  Displays an thumbnail capture of a video given a video source 
/// </summary> 
public class CcsThumbnailDisplay : Control 
{ 
    #region Dependency Property Definitions 

    /// <summary> 
    ///  ThumbnailSource Dependency Property 
    /// </summary> 
    public static readonly DependencyProperty ImageSourceProperty = DependencyProperty.Register(
     "ThumbnailSource", typeof(ImageSource), typeof(CcsThumbnailDisplay), 
     new PropertyMetadata(null, new PropertyChangedCallback(CcsThumbnailDisplay.OnThumbnailSourcePropertyChanged))); 

    /// <summary> 
    ///  ChannelLabel Dependency Property 
    /// </summary> 
    public static readonly DependencyProperty ChannelLabelProperty = DependencyProperty.Register(
     "ChannelLabel", typeof(String), typeof(CcsThumbnailDisplay), 
     new PropertyMetadata("n/a", new PropertyChangedCallback(CcsThumbnailDisplay.OnChannelLabelPropertyChanged))); 

    #endregion 
    #region Data Properties 

    /// <summary> 
    ///  The thumbnail source for the video stream 
    /// </summary> 
    public ImageSource ThumbnailSource 
    { 
     get { return (ImageSource)GetValue(CcsThumbnailDisplay.ImageSourceProperty); } 
     set { SetValue(CcsThumbnailDisplay.ImageSourceProperty, value); } 
    } 

    /// <summary> 
    ///  The channel label for the video stream 
    /// </summary> 
    public String ChannelLabel 
    { 
     get { return (String)GetValue(CcsThumbnailDisplay.ChannelLabelProperty); } 
     set { SetValue(CcsThumbnailDisplay.ChannelLabelProperty, value); } 
    } 

    #endregion 
    #region Object Construction 

    /// <summary> 
    ///  Constructs a thumbnial display Control 
    /// </summary> 
    public CcsThumbnailDisplay() 
    { 
     this.DefaultStyleKey = typeof(CcsThumbnailDisplay); 
    } 

    /// <summary> 
    ///  Invoked when the template is applied 
    /// </summary> 
    public override void OnApplyTemplate() 
    { 
     base.OnApplyTemplate(); 

     //this.Background = new ImageBrush() 
     //{ 
     // ImageSource = this.ThumbnailSource, 
     // Stretch = Stretch.Fill 
     //}; 
    } 

    #endregion 
    #region Control Event Handling 

    private void OnThumbnailSourceChanged(DependencyPropertyChangedEventArgs e) 
    { 
     //this.Background = new ImageBrush() 
     //{ 
     // ImageSource = this.ThumbnailSource, 
     // Stretch = Stretch.Fill 
     //}; 
    } 

    private void OnChannelLabelChanged(DependencyPropertyChangedEventArgs e) 
    { 
    } 

    #endregion 
    #region Static Property Dependency Handling 

    private static void OnThumbnailSourcePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) 
    { 
     //CcsThumbnailDisplay objChange = d as CcsThumbnailDisplay; 

     //if (d == null) 
     // return; 

     //objChange.OnThumbnailSourceChanged(e); 
    } 

    private static void OnChannelLabelPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) 
    { 
     //CcsThumbnailDisplay objChange = d as CcsThumbnailDisplay; 

     //if (d == null) 
     // return; 

     //objChange.OnChannelLabelChanged(e); 
    } 

    #endregion 
} 

}

ответ

2

Существуют соглашения об именах для свойств зависимостей. Переименование ImageSourceProperty - ThumbnailSourceProperty:

public static readonly DependencyProperty ThumbnailSourceProperty = 
    DependencyProperty.Register("ThumbnailSource", ...); 

public ImageSource ThumbnailSource 
{ 
    get { return (ImageSource)GetValue(ThumbnailSourceProperty); } 
    set { SetValue(ThumbnailSourceProperty, value); } 
} 
Смежные вопросы