diff options
author | 조규호/Tizen Platform Lab(S/W센터)/Senior Engineer/삼성전자 <kyuho.jo@samsung.com> | 2017-08-18 10:29:58 +0900 |
---|---|---|
committer | GitHub Enterprise <noreply-CODE@samsung.com> | 2017-08-18 10:29:58 +0900 |
commit | 8d031b540d7693487b4acbfbf17f3ab4016c0a9e (patch) | |
tree | 4dbd2165a4280397dedc45ceea922d940ad3a159 | |
parent | 18581f76ca9e3e7e7ccc8fe06d77fd6ec3143b3f (diff) | |
parent | 9e040eedf94fabe7be8cbab715a5342bac94d2a6 (diff) | |
download | videoplayer-8d031b540d7693487b4acbfbf17f3ab4016c0a9e.tar.gz videoplayer-8d031b540d7693487b4acbfbf17f3ab4016c0a9e.tar.bz2 videoplayer-8d031b540d7693487b4acbfbf17f3ab4016c0a9e.zip |
Merge pull request #57 from RS7-TizenReferenceSampleApplication/nicesj.park
Set focus on the layout when it is done to build.
-rw-r--r-- | NewPlayer/NewPlayer/Views/LibraryPage.xaml.cs | 35 |
1 files changed, 30 insertions, 5 deletions
diff --git a/NewPlayer/NewPlayer/Views/LibraryPage.xaml.cs b/NewPlayer/NewPlayer/Views/LibraryPage.xaml.cs index fdf649c..5a3761a 100644 --- a/NewPlayer/NewPlayer/Views/LibraryPage.xaml.cs +++ b/NewPlayer/NewPlayer/Views/LibraryPage.xaml.cs @@ -28,11 +28,6 @@ namespace NewPlayer.Views GridView.Children.Add(new ItemView(item), index / 3, index % 3); index++; } - - if (index > 0) - { - GridView.Children[0].FindByName<Button>("FocusButton")?.Focus(); - } } private void OnPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) @@ -42,10 +37,40 @@ namespace NewPlayer.Views UpdateGridItems(); } } + + protected override void OnAppearing() + { + base.OnAppearing(); + + GridView.LayoutChanged += OnGridViewLayoutChanged; + } + + private void OnGridViewLayoutChanged(object sender, System.EventArgs e) + { + if (GridView.Children != null && GridView.Children.Count > 0) + { + var item = GridView.Children[0]; + if (item != null) + { + item.FindByName<Button>("FocusButton")?.Focus(); + } + } + } + public LibraryPage() { InitializeComponent(); + PropertyChanged += OnPropertyChanged; + + // In a case of Tizen, the Items property is ready before initializing the LibraryView. + // Therefore, the property changed event can be skipped. + // To prevent from missing the changed event, we should check the Items first. + // If it is ready, we can update the Grid. + if (Items != null) + { + UpdateGridItems(); + } } } } |