3

我正在为 Windows 8 商店应用程序使用 XAML FlipView 控件。

当我使用鼠标并且鼠标位于 FlipView 控件上时,会显示上一个/下一个导航按钮。

但是,如果我不使用鼠标并使用触摸,导航按钮就会隐藏。

我希望导航按钮始终可见。我怎样才能做到这一点?

我查看了控件模板,但我看不到任何设置导航按钮可见性的内容。

4

1 回答 1

2

尝试动态隐藏/显示按钮

private void Show(object sender, RoutedEventArgs e)
{
    ButtonShow(fv, "PreviousButtonHorizontal");
    ButtonShow(fv, "NextButtonHorizontal");
    ButtonShow(fv, "PreviousButtonVertical");
    ButtonShow(fv, "NextButtonVertical");
}
private void Hide(object sender, RoutedEventArgs e)
{
    ButtonHide(fv, "PreviousButtonHorizontal");
    ButtonHide(fv, "NextButtonHorizontal");
    ButtonHide(fv, "PreviousButtonVertical");
    ButtonHide(fv, "NextButtonVertical");
}
private void ButtonHide(FlipView f, string name)
{
    Button b;
    b = FindVisualChild<Button>(f, name);
    b.Opacity = 0.0;
    b.IsHitTestVisible = false;
}
private void ButtonShow(FlipView f, string name)
{
    Button b;
    b = FindVisualChild<Button>(f, name);
    b.Opacity = 1.0;
    b.IsHitTestVisible = true;
}
private childItemType FindVisualChild<childItemType>(DependencyObject obj, string name) where childItemType : FrameworkElement
{
    // Exec
    for (int i = 0; i < VisualTreeHelper.GetChildrenCount(obj); i++)
    {
        DependencyObject child = VisualTreeHelper.GetChild(obj, i);
        if (child is childItemType && ((FrameworkElement)child).Name == name)
            return (childItemType)child;
        else
        {
            childItemType childOfChild = FindVisualChild<childItemType>(child, name);
            if (childOfChild != null)
                return childOfChild;
        }
    }
    return null;
}
于 2013-12-16T11:02:00.983 回答