Setting focus to a PanoramaItem

两盒软妹~` 提交于 2019-12-08 03:15:27

问题


Is there a way to set focus to a PanoramaItem in Silverlight for Windows Phone 7?

I've tried:

piResults.Focus();

Where piResults is the name of a PanoramaItem. I've also tried to give focus to one of the controls in the PanoramaItem, but that didn't work either.

If this isn't clear, I'm trying to do the following: If you press a button on one PanoramaItem, you go to another.


回答1:


Have you tried setting the index of the PanoramaItem programatically, like -

piResults.DefaultItem = piResults.Items[_panorama_item_index_];

This technique is useful during Tombstoning. Here is the XAML for the Panorama control that I tried -

<!--Panorama item one-->
<controls:PanoramaItem Header="first item">
    <!--Double line list with text wrapping-->
    <Button x:Name="FirstButton" Content="Go to second item"
            Click="FirstButton_Click"/>

</controls:PanoramaItem>

<!--Panorama item two-->
<!--Use 'Orientation="Horizontal"' to enable a panel that lays out horizontally-->
<controls:PanoramaItem Header="second item">
    <!--Double line list with image placeholder and text wrapping-->
    <Button x:Name="SecondButton" Content="Go to first item"
            Click="SecondButton_Click"/>
</controls:PanoramaItem>

The events handlers are -

private void SecondButton_Click(object sender, RoutedEventArgs e)
{
  piResults.DefaultItem = piResults.Items[0];
}

private void FirstButton_Click(object sender, RoutedEventArgs e)
{
  piResults.DefaultItem = piResults.Items[1];
}

Hope this helps. indyfromoz



来源:https://stackoverflow.com/questions/3953200/setting-focus-to-a-panoramaitem

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!