开发者

Saving focus state using GetFocusedElement() not working with user controls on a Panorama control

I am trying to use the 'best practice' technique of using the

FocusManager.GetFocusedElement()

in the OnNavigatedFrom event and

this.FindName

to locate the focused control in the OnNavigatedTo event.

I have a Panorama page and within each PanoramaItem I have a user control which in turn have many controls such as TextBox's etc..

The GetFocusedElement does retrieve the focused con开发者_运维问答trols name in the user controls, but the FindName method then fails to find it on return! The name returned does not include any reference to the user control itself, so I am assuming the FindName does not traverse user controls!

Am I doing something wrong or does anyone know a way of easily improving this, or at least a simple technique for at least showing or navigating too the last PanoramaItem that was displayed before the app is deactivated?


To set the selected panorama item when the page is navigated to use the DefaultItem property.

To determine what this should be, save the SelectedItem when navigating away from the page.

You should be doing this at the page level and accessing properties of the panorama. There should be no need to do anything in the controls hosted in a panoramaItem whether they are user controls or not.

If you wish to avoid the side effects of altering the defaultItem, you may want to have a look at http://blogs.ugidotnet.org/corrado/archive/2010/09/27/smartpanorama-a-panorama-control-extension.aspx

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜