我的公司被困在.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