2010-08-13 49 views
1

我一直在努力得到這個例子的工作,但似乎有代碼標籤目標代碼中的錯誤,因爲當你點擊第二個標籤時,焦點被設置爲DatePicker而不是TextBox,無論您首先點擊哪個標籤,當您輸入日期時,第二個標籤仍將其設置爲DatePicker。Label Target =「{Binding ElementName = UIName}」錯誤,還是僅僅是我?

<!-- Unbound Date of Birth field --> 
<sdk:Label Content="Date of Birth" IsRequired="True" Margin="5" /> 
<StackPanel Orientation="Horizontal" Grid.Column="1"> 
    <sdk:DatePicker Height="23" /> 
    <sdk:DescriptionViewer Description="Please enter your date of birth."/> 
</StackPanel> 

<!-- ID Number field --> 
<sdk:Label Grid.Row="1" Margin="5" Target="{Binding ElementName=tbIdNumber}" /> 
<StackPanel Orientation="Horizontal" Grid.Column="1" Grid.Row="1"> 
    <TextBox x:Name="tbIdNumber" Height="23" Width="100" 
      Text="{Binding IdNumber, Mode=TwoWay, 
        ValidatesOnExceptions=True, NotifyOnValidationError=True}" /> 
    <sdk:DescriptionViewer Target="{Binding ElementName=tbIdNumber}"/> 
</StackPanel> 

我在MSDN link text上找到了這個例子。對我來說,這似乎是一個錯誤,或者我只是失去了它?

道歉,如果這是一個重複的問題...我GOOGLE了這一點,所有的例子似乎是相同的,因爲目標元素沒有被關注。

回答

1

這似乎是一個合理的假設,點擊標籤應該將焦點移到關聯的控件。但是Label實際上並不提供該功能。

+0

另一個問題,如果我可以,爲什麼你想要以他們的方式綁定標籤?它似乎沒有用於有用的目的。 我正在看它,就像HTML標籤一樣,因爲它有一個控件的目標,你會認爲它會對它做些什麼。 – Paul 2010-08-13 22:42:36

+0

啊,是的,我現在看到它..感謝花時間來解釋它。 – Paul 2010-08-14 00:25:52

相關問題