我无法弄清楚如何将DependencyProperty的VB代码转换为C#代码。
我已阅读this文章......但无论如何我需要一些帮助。
Public Shared VideoDirectoryProperty As DependencyProperty = _
DependencyProperty.Register("VideoDirectory", GetType(String), GetType(Webcam), _
New FrameworkPropertyMetadata(New PropertyChangedCallback(AddressOf DirectoryChange)))
Private Shared Sub DirectoryChange(ByVal source As DependencyObject, ByVal e As DependencyPropertyChangedEventArgs)
End Sub
我得到了和C#代码:
public DependencyProperty VideoDirectoryProperty = DependencyProperty.Register("VideoDirectory", typeof(string), typeof(WCam),
new FrameworkPropertyMetadata(new PropertyChangedCallback(DirectoryChange)));
private void DirectoryChange(DependencyObject source, DependencyPropertyChangedEventArgs e )
{
}
答案 0 :(得分:1)
您似乎需要将VideoDirectoryProperty
定义为静态,因为您的VB代码是Shared
。
此外,您在VB中有GetType(WebCam)
但在C#中有typeof(WCam)
。
public static readonly DependencyProperty VideoDirectoryProperty =
DependencyProperty.Register(
"VideoDirectory",
typeof(string),
typeof(WebCam),
new FrameworkPropertyMetadata(new PropertyChangedCallback(DirectoryChange)));
private static void DirectoryChange(
DependencyObject source, DependencyPropertyChangedEventArgs e)
{
}