XAML 在类型“CcsThumbnailDisplay”上找不到静态成员“ThumbnailSourceProperty”

lzfw57am  于 2022-12-07  发布在  其他
关注(0)|答案(1)|浏览(128)

我正在将代码从Silverlight转换为WPF,但我希望应用程序以后可以在这两种环境中工作。因此,我将Silverlight文件链接到新的WPF项目。当我将其转换为WPF项目时,出现以下错误:
错误1无法在类型'CcsThumbnailDisplay'上找到静态成员'ThumbnailSourceProperty'。C:\用户\桌面\控制台\控制台2\leitch\HarrisSilverlightToolkit\Toolkit\Source\控制台\显示控制台\流式处理\主题\CcsThumbnailDisplay.xaml 22 109显示控件
我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
}

}

x4shl7ld

x4shl7ld1#

相依性属性有命名惯例。请将ImageSourceProperty重新命名为ThumbnailSourceProperty

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

public ImageSource ThumbnailSource
{
    get { return (ImageSource)GetValue(ThumbnailSourceProperty); }
    set { SetValue(ThumbnailSourceProperty, value); }
}

相关问题