我有一些頁面TextBox或PhoneTextBox(來自工具包):xaml代碼的一部分。 我動畫scrollviewer(不透明度和XProperty),befor我設置文本框的datacotext。Windows Phone 8在TextBox或PhoneTextBox中輸入緩慢的文本
<ScrollViewer x:Name="ContentScroller"
Visibility="Collapsed"
Margin="35,0,35,0">
<ScrollViewer.RenderTransform>
<TranslateTransform />
</ScrollViewer.RenderTransform>
<Grid x:Name="ContentGrid">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock x:Name="CreationgDate"
Text="{Binding CreationDate, StringFormat='Created: {0:dd.MM.yyyy HH:mm}'}"
Style="{StaticResource CreationDateTextStyle}"
Grid.Row="0"/>
<toolkit:PhoneTextBox x:Name="BodyData"
InputScope="Chat"
Text="{Binding Body, UpdateSourceTrigger=Explicit}"
LostFocus="BodyData_LostFocus"
TextWrapping="Wrap"
AcceptsReturn="True"
Grid.Row="1">
</toolkit:PhoneTextBox>
</Grid>
</ScrollViewer>
我在事件LostFocus更新數據源:
// this I set datacontex
private async void Item_Click(object sender, RoutedEventArgs e)
{
PageHeader.DataContext = CreationgDate.DataContext = BodyData.DataContext = activeItem;
await AnimateChangePage();
}
private void BodyData_LostFocus(object sender, RoutedEventArgs e)
{
BindingExpression be = NoteBodyData.GetBindingExpression(PhoneTextBox.TextProperty);
be.UpdateSource();
}
故障:在文本框中的文本有400-500個字符多,然後在文本框非常緩慢的文字輸入和鍵盤有一個滯後反應。 我測試應用程序在真實設備(不是模擬器),其他應用程序具有相同的功能(從應用程序商店)工作正常,沒有滯後和緩慢的輸入。
請幫我解決這個問題。 對不起我的郎(不是英文:) :)。
我還沒有使用過這麼長的文本框,但是作爲一個測試,如果你將綁定從Explicit改變爲LostFocus並且擺脫了lostFocus事件呢? msdn.microsoft.com/en-us/library/system.windows.data.updatesourcetrigger(v=vs.110).aspx – HockeyJ
我的第一個變種:'Text =「{Binding Body,Mode = TwoWay}」',默認UpdateSourceTrigger,但結果相同。 – f14shm4n
很難說。通常,這種減速是由於對象更新後在後臺發生大量通知而引起的。您的模型是從BindableBase繼承的,還是您使用的是MVVM框架? – HockeyJ