Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在哪里可以找到列表中可单击项目使用的Windows Phone按钮样式?_C#_Wpf_Xaml_Windows Phone 8 - Fatal编程技术网

C# 在哪里可以找到列表中可单击项目使用的Windows Phone按钮样式?

C# 在哪里可以找到列表中可单击项目使用的Windows Phone按钮样式?,c#,wpf,xaml,windows-phone-8,C#,Wpf,Xaml,Windows Phone 8,在内置Windows Phone应用程序中,列表中的可单击项(StackPanel或LongListSelector)通常具有以下行为: 单击/轻敲并按住时,项目会收缩 单击/点击并保持1秒时,弹出关联菜单 如果指针在按住的同时移动了一定数量的像素,则点击操作将中止 在all apps(所有应用程序)视图中可以很容易地观察到这种行为(当您向左滑动主屏幕时,会看到该屏幕)。因为2+3。已由按钮和1处理。使用一种样式很容易实现,在按下按钮时收缩所有内容,我很确定列表中的项目使用样式化的按钮作为项目模

在内置Windows Phone应用程序中,列表中的可单击项(StackPanel或LongListSelector)通常具有以下行为:

  • 单击/轻敲并按住时,项目会收缩
  • 单击/点击并保持1秒时,弹出关联菜单
  • 如果指针在按住的同时移动了一定数量的像素,则点击操作将中止
  • 在all apps(所有应用程序)视图中可以很容易地观察到这种行为(当您向左滑动主屏幕时,会看到该屏幕)。因为2+3。已由按钮和1处理。使用一种样式很容易实现,在按下按钮时收缩所有内容,我很确定列表中的项目使用样式化的按钮作为项目模板,其样式与默认按钮样式不同


    我在哪里可以找到这种风格?

    您可以从以下给定链接下载演示应用程序:

    倾斜效应连杆
    上下文菜单的链接
    根据普拉迪普的回答,我可以解决这个问题。可点击的项目不是按钮,尽管也可以实现与按钮样式相同的行为(参见本答案底部)。抽头效应时的收缩实际上是抽头效应时的倾斜,如果该项目在左边或右边,而不是在中间,则对细心观察者来说是可见的。p> 如果为
    LongListSelector
    启用了倾斜效果,则倾斜将应用于单个
    LongListSelector
    项目<代码>倾斜效果是附加属性。要使用它,项目必须引用nuget上提供的Microsoft

    我在下面附上的代码显示了如何在
    LongListSelector
    中使用
    TiltEffect
    ContextMenu
    。要对单击长列表选择器中的项目作出反应,请参阅

    
    
    或者,外观和行为相同的按钮样式可以使用相同的附加属性来实现,大致如下所示:

    <Style x:Key="ListButton" TargetType="Button">
        <Setter Property="HorizontalAlignment" Value="Stretch" />
        <Setter Property="HorizontalContentAlignment" Value="Left" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="BorderThickness" Value="0" />
        <Setter Property="FontFamily" Value="{StaticResource PhoneFontFamilyLight}" />
        <Setter Property="FontSize" Value="{StaticResource PhoneFontSizeLarge}" />
        <!-- Transparent background is necessary to be part of hitbox. transparent background and null background behave differently -->
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="Padding" Value="0" />
        <Setter Property="toolkit:TiltEffect.IsTiltEnabled" Value="True" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Button">
                    <Border BorderThickness="{TemplateBinding BorderThickness}" HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
                                BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}">
                        <ContentPresenter Content="{TemplateBinding Content}" Margin="{TemplateBinding Padding}" 
                                   HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    
    
    *此样式是最小的,并且不考虑所有情况(例如禁用/启用)

    <Style x:Key="ListButton" TargetType="Button">
        <Setter Property="HorizontalAlignment" Value="Stretch" />
        <Setter Property="HorizontalContentAlignment" Value="Left" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="BorderThickness" Value="0" />
        <Setter Property="FontFamily" Value="{StaticResource PhoneFontFamilyLight}" />
        <Setter Property="FontSize" Value="{StaticResource PhoneFontSizeLarge}" />
        <!-- Transparent background is necessary to be part of hitbox. transparent background and null background behave differently -->
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="Padding" Value="0" />
        <Setter Property="toolkit:TiltEffect.IsTiltEnabled" Value="True" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Button">
                    <Border BorderThickness="{TemplateBinding BorderThickness}" HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
                                BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}">
                        <ContentPresenter Content="{TemplateBinding Content}" Margin="{TemplateBinding Padding}" 
                                   HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>