我的公司被困在.Net 3.0中。我試圖解決的任務很簡單,我需要將CheckBoxResolvesCEDAR的IsChecked屬性綁定到我的Audio類中的CompletesCEDARWork。我對此的瞭解越多,似乎我必須將CompletesCEDARWork聲明爲依賴屬性,但我無法找到這是如何完成的一個好例子。我找到了這個例子,但是當我粘貼到我的代碼中時,GetValue出現「未定義」錯誤,而且我還沒有成功找出MyCode應該代表什麼。任何幫助/例子將不勝感激。如何在VB.Net 3.0中聲明一個依賴屬性
感謝
Public Shared ReadOnly IsSpinningProperty As DependencyProperty = DependencyProperty.Register("IsSpinning", GetType(Boolean), GetType(MyCode))
Public Property IsSpinning() As Boolean
Get
Return CBool(GetValue(IsSpinningProperty))
End Get
Set(ByVal value As Boolean)
SetValue(IsSpinningProperty, value)
End Set
End Property
這裏是我的slimed下來音頻類,因爲它現在站立。
Imports System.Xml
進口系統 進口System.IO 進口System.Collections.ObjectModel 進口System.ComponentModel
公共類音頻
Private mXMLString As String
Private mTarpID As Integer
Private mStartTime As Date
Private mEndTime As Date
Private mAudioArray As Byte()
Private mFileXMLInfo As IO.FileInfo
Private mFileXMLStream As IO.FileStream
Private mFileAudioInfo As IO.FileInfo
Private mDisplayText As String
Private mCompletesCEDARWork As Boolean
Private Property CompletesCEDARWork() As Boolean
Get
Return mCompletesCEDARWork
End Get
Set(ByVal value As Boolean)
mCompletesCEDARWork = value
End Set
End Property
,這裏是我的XML DataTemplate中,我設定的捆綁。
<DataTemplate x:Key="UploadLayout" DataType="Audio">
<Border BorderBrush="LightGray" CornerRadius="8" BorderThickness="1" Padding="10" Margin="0,3,0,0">
<StackPanel Orientation="Vertical">
<TextBlock Text="{Binding Path=DisplayText}">
</TextBlock>
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
<TextBlock Text="TARP ID" VerticalAlignment="Center"/>
<ComboBox x:Name="ListBoxTarpIDs"
ItemsSource="{Binding Path=TarpIds}"
SelectedValue="{Binding Path=TarpID}"
BorderBrush="Transparent"
Background="Transparent" >
</ComboBox>
</StackPanel>
<CheckBox x:Name="CheckBoxResolvesCEDAR"
Content="Resolves CEDAR Work"
IsChecked="{Binding ElementName=Audio,Path=CompletesCEDARWork,Mode=TwoWay}"/>
</StackPanel>
</Border>
</DataTemplate>
實現INotifyPropertyChanged的代碼,它完美地工作。謝謝! – user38349 2010-05-15 16:42:48