【问题标题】:ListBox in Popup WP7弹出 WP7 中的列表框
【发布时间】:2011-08-22 19:18:43
【问题描述】:

我正在尝试为 Windows Phone 7 应用程序的搜索建议/历史创建自定义弹出窗口,但我遇到了一些我无法解决的问题。

我在弹出窗口中使用 ListBox 来显示我的结果,但是,

a) 我的项目没有正确显示,它列出了从 -1 位置开始的项目???在 ListBox 中,但当被选中时,它们会给出下面的值。

b) 在我的页面中,我有一个显示搜索结果的列表框,并且我的弹出建议显示在此列表框上(在文本框下方),当我滚动/选择建议时,下方的列表框会滚动并选择项目。

请问有人知道解决方法或解决方法吗?

这是我的(简化的)代码:

<Popup Name="AutoCompleteList">
    <Border Background="White" BorderThickness="1" BorderBrush="Black" HorizontalAlignment="Center">
        <ListBox x:Name="ListItems" HorizontalAlignment="Left" Height="Auto">
            <ListBoxItem>
                <TextBlock Text="Test1" Foreground="Black" />
            </ListBoxItem>
            <ListBoxItem>
                <TextBlock Text="Test2" Foreground="Black" />
            </ListBoxItem>
            <ListBoxItem>
                <TextBlock Text="Test3" Foreground="Black" />
            </ListBoxItem>
            <ListBoxItem>
                <TextBlock Text="Test4" Foreground="Black" />
            </ListBoxItem>
            <ListBoxItem>
                <TextBlock Text="Test5" Foreground="Black" />
            </ListBoxItem>
            <ListBoxItem>
                <TextBlock Text="Test6" Foreground="Black" />
            </ListBoxItem>
            <ListBoxItem>
                <TextBlock Text="Test7" Foreground="Black" />
            </ListBoxItem>
            <ListBoxItem>
                <TextBlock Text="Test8" Foreground="Black" />
            </ListBoxItem>
            <ListBoxItem>
                <TextBlock Text="Test9" Foreground="Black" />
            </ListBoxItem>
            <ListBoxItem>
                <TextBlock Text="Test10" Foreground="Black" />
            </ListBoxItem>
        </ListBox>
    </Border>
</Popup>

谢谢。

【问题讨论】:

    标签: silverlight windows-phone-7


    【解决方案1】:

    a) ListBox 初始 SelectedIndex 始终是 -1

    b) 听起来像是预期的行为。没有其余的代码就不可能说出来。

    然而如果你想要一个 AutoCompleteBox,你应该使用Silverlight Toolkit 中的AutoCompleteBox。你可以阅读一下here

    【讨论】:

      【解决方案2】:

      我发现了我的问题。

      a) 我在承载我的 UserControl 的页面中使用 wp7 工具包的十字转门过渡效果进行精美导航,这影响了弹出窗口中 ListBox 的视觉效果:

          <toolkit:TransitionService.NavigationInTransition>
          <toolkit:NavigationInTransition>
              <toolkit:NavigationInTransition.Backward>
                  <toolkit:TurnstileTransition Mode="BackwardIn"/>
              </toolkit:NavigationInTransition.Backward>
              <toolkit:NavigationInTransition.Forward>
                  <toolkit:TurnstileTransition Mode="ForwardIn"/>
              </toolkit:NavigationInTransition.Forward>
          </toolkit:NavigationInTransition>
      </toolkit:TransitionService.NavigationInTransition>
      <toolkit:TransitionService.NavigationOutTransition>
          <toolkit:NavigationOutTransition>
              <toolkit:NavigationOutTransition.Backward>
                  <toolkit:TurnstileTransition Mode="BackwardOut"/>
              </toolkit:NavigationOutTransition.Backward>
              <toolkit:NavigationOutTransition.Forward>
                  <toolkit:TurnstileTransition Mode="ForwardOut"/>
              </toolkit:NavigationOutTransition.Forward>
          </toolkit:NavigationOutTransition>
      </toolkit:TransitionService.NavigationOutTransition>
      

      b) 我使用工具包(再次):LongListSelector 作为搜索结果的列表框,该控件从浮动在其上方的弹出窗口中窃取鼠标操作,但使用标准列表框控件效果很好。

      哇!

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-03-29
        • 2012-05-23
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多