1

我認爲這是非常標準的,以獲得UWP:軟鍵盤不會滾動聚焦文本框(嵌套在一個FlipView)到視圖

「滾動聚焦文本框進入視野時,會出現軟鍵盤」

但我花費的時間越多,試圖解決這個問題,就越覺得它除以零。

我用flipview寫了一個應用程序,用程序創建的頁面填充。

我的應用程序進入ViewModelFirst,因此Xaml-Views通過DataTemplateSelector從ResourceDictionary加載。

MainPage(xaml-page - 不是來自ResourceDictionary)底部的TextBox有效。

只要頁面來自DataTemplateSelector(因此必然來自ResourceDictionary),它就不會像預期那樣工作。

順便說一句:我決定採用ResourceDictionary的方式,因爲從我看來不可能從xaml頁面獲取DataTemplate。如果有人知道這樣做的方式,請告訴我:)

因此,這裏是我的示例項目: https://drive.google.com/file/d/0BzDVtvE9NKaMd2dBMWMzTWJtN1E/view?usp=sharing

謝謝大家提前

問候 亞歷

+1

@清道夫我該怎麼做?我只找到了Xamarin-lib的例子。 –

回答

1

我解決了這個通過將FlipView的ItemsPanel更改爲水平滾動的StackPanel。默認情況下,VirtualizingStackPanel正在使用中。

我的方法是這樣的:

private ItemsPanelTemplate GetItemsPanelTemplate() { 
      string xaml = "<ItemsPanelTemplate xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'><StackPanel Orientation='Horizontal' AreScrollSnapPointsRegular='True' /></ItemsPanelTemplate>"; 
      return XamlReader.Load(xaml) as ItemsPanelTemplate; 
     } 

而且我把這種方法是這樣的:

Flip.ItemsPanel = GetItemsPanelTemplate(); 

在這裏,我要感謝feO2x(https://stackoverflow.com/users/1560623/feo2x),他在他的博客文章(http://www.feo2x.com/posts/2015-12-06-flipview-and-problems-with-input-controls-part-1/

但要注意: 根據feO2x的博客帖子的VirtualizingStackPanel使用一種延遲加載,但現在使用(標準)StackPanel不。 所以它可能會變慢。

我希望這可以幫助別人。

相關問題