开发者

WP7 ListPicker on Popup causing Back button problems

开发者 https://www.devze.com 2023-02-14 07:04 出处:网络
I am using the WP7 Tookit ListPicker (Feb release) on a Popup Control. I have trapped the Back button so I can close the popup.

I am using the WP7 Tookit ListPicker (Feb release) on a Popup Control. I have trapped the Back button so I can close the popup.

If I press the back button while the ListPicker is open in popup mode, my back button event handler is firing before the ListPicker handles it so both the ListPicker and my popup are closing.

One way I thought of handling it was to check and see if I have any ListPickers on the popup that are open and if so close the and cancel the navigation (the controls on my popup are added dynamically so I have to enumerate through the popup child controls to check) but I can't find a way of seeing if the ListPicker is Open or Closing it.

So my question is a) is there a way of handling this in t开发者_开发知识库he back button handler and if not b) how can I check if a ListPicker is Open.


In your popup control's BackKeyPress callback add the following check:

if( myListPicker.ListPickerMode == ListPickerMode.Normal ) {
  // Close popup

  // Cancel navigation
  e.Cancel = true;
}

When ListPickerMode is Expanded or Full the ListPicker will catch the back key pressed event and close itself.

EDIT:

According to @SteveChadbourne's comment the following worked:

if( myListPicker.ListPickerMode != ListPickerMode.Normal ) {
  // Close the ListPicker
  myListPicker.ListPickerMode = ListPickerMode.Normal;

  // Cancel navigation
  e.Cancel = true;

}
0

精彩评论

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