VB.netでVisual Studio 2008を使用する3.5。与えられたとして、古いIDEを使用してconverter.telerik.comVB.netでVS 2008でDependencyPropertyの新しいUIPropertyMetadataを実装する
Public Shared ReadOnly CommandProperty As DependencyProperty = DependencyProperty.RegisterAttached("Command", GetType(ICommand), GetType(GridViewSort), New UIPropertyMetadata(Nothing, Function(o, e)
Dim listView As ItemsControl = TryCast(o, ItemsControl)
If listView IsNot Nothing Then
If Not GetAutoSort(listView) Then
' Don't change click handler if AutoSort enabled
If e.OldValue IsNot Nothing AndAlso e.NewValue Is Nothing Then
listView.[RemoveHandler](GridViewColumnHeader.ClickEvent, New RoutedEventHandler(AddressOf ColumnHeader_Click))
End If
If e.OldValue Is Nothing AndAlso e.NewValue IsNot Nothing Then
listView.[AddHandler](GridViewColumnHeader.ClickEvent, New RoutedEventHandler(AddressOf ColumnHeader_Click))
End If
End If
End If
End Function))
によってVB.netに変換[WPF] AUTOMATICALLY SORT A GRIDVIEW WHEN A COLUMN HEADER IS CLICKED by Thomas Levesque
彼のコードからソートソリューションを実装しようとすると、私はそれを使用することはできません。私は関数を通常の関数に変換しようとしましたが、o
とe
がどこから来たのか分かりません。
Public Shared ReadOnly CommandProperty As DependencyProperty = DependencyProperty.RegisterAttached("Command", GetType(ICommand), GetType(GridViewSort), New UIPropertyMetadata(Nothing, getFuncA))
Public Shared Function getFuncA(ByVal o As DependencyObject, ByVal e As DependencyPropertyChangedEventArgs)
Dim listView As ItemsControl = TryCast(o, ItemsControl)
If listView IsNot Nothing Then
If Not GetAutoSort(listView) Then
' Don't change click handler if AutoSort enabled
If e.OldValue IsNot Nothing AndAlso e.NewValue Is Nothing Then
listView.[RemoveHandler](GridViewColumnHeader.ClickEvent, New RoutedEventHandler(AddressOf ColumnHeader_Click))
End If
If e.OldValue Is Nothing AndAlso e.NewValue IsNot Nothing Then
listView.[AddHandler](GridViewColumnHeader.ClickEvent, New RoutedEventHandler(AddressOf ColumnHeader_Click))
End If
End If
End If
End Function
o is not declared
とe is not declared
コンパイラエラー。 VS 2008を使ってこれをVB.net 3.5に変換するにはどうすればいいですか。ありがとう。
'o'と' e'は 'のDependencyObject O、DependencyPropertyChangedEventArgs e'する必要がありますを使用していました新しい価値。 DP変更に関するイベントはフレームワークによって生成されます。 getFuncA宣言はikeイベントハンドラのように見えます – ASh
@AShありがとうございました。それはまさに私が欠けていたものです。私は 'getFuncA'を' AddressOf getFuncA'に変更しました。 'UIPropertyMetadata'が必要としたものを理解していませんでした。 –