Search code examples
c#wpfxamlsilverlight

Cannot find the static member 'ThumbnailSourceProperty' on the type 'CcsThumbnailDisplay'


I am converting code from Silverlight to WPF, but I want the application to later work in both. So I am linking the Silverlight files to new WPF projects. I am getting this error when I convert it to a WPF project:

Error 1 Cannot find the static member 'ThumbnailSourceProperty' on the type 'CcsThumbnailDisplay'. C:\Users\sahluwai\Desktop\cusControls2\leitch\HarrisSilverlightToolkit\Toolkit\Source\Controls\DisplayControls\Streaming\Themes\CcsThumbnailDisplay.xaml 22 109 DisplayControls

my xaml code is:

<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>

my code behind file is:

   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
}

}


Solution

  • There are naming conventions for dependency properties. Rename ImageSourceProperty to ThumbnailSourceProperty:

    public static readonly DependencyProperty ThumbnailSourceProperty =
        DependencyProperty.Register(nameof(ThumbnailSource), ...); 
    
    public ImageSource ThumbnailSource
    {
        get { return (ImageSource)GetValue(ThumbnailSourceProperty); }
        set { SetValue(ThumbnailSourceProperty, value); }
    }