因此,在開發Windows Phone 8應用程序時,我遇到了以下工具包問題。WP工具包DatePicker不會更新值
編輯:以下是其重現該問題的頁面的完整代碼:
<phone:PhoneApplicationPage
x:Class="TestPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
mc:Ignorable="d"
shell:SystemTray.IsVisible="True">
<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="Transparent">
<toolkit:DatePicker x:Name="MyDate" />
</Grid>
</phone:PhoneApplicationPage>
這看起來正確的,並讓用戶選擇一個日期,但從來沒有更新自己的價值。點擊它後,您將看到日期選擇頁面。無論您在此頁面上做了什麼,當您返回DatePicker時都會將其設置回今天的日期。
我成功地在另一頁上使用DatePicker。這是在我遇到此問題的特定頁面上。
我真正的問題是,我該如何調試這個元素的行爲?如何確定在選擇其他日期時導致元素不更新的原因?
編輯2: 很明顯,我的應用程序還有其他的東西在這裏。因此我需要調試一個正在運行的元素,或者至少了解它爲什麼沒有達到我期望的效果。
我們可以看到代碼的其餘部分對於這個特定的頁面? –
你可以,但我不想給你造成負擔。我知道這是多麼惱人的「這是我的代碼,請讓它工作」的問題是...這就是爲什麼我只是問如何調試它。當我今晚回到家時,我會嘗試將頁面代碼減少到再現錯誤的最小示例,然後我會發布該代碼。 –
已添加頁面代碼。 –