Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/324.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# ListPicker Blend/Xaml的设计_C#_Xaml_Windows Phone 8_Expression Blend_Listpicker - Fatal编程技术网

C# ListPicker Blend/Xaml的设计

C# ListPicker Blend/Xaml的设计,c#,xaml,windows-phone-8,expression-blend,listpicker,C#,Xaml,Windows Phone 8,Expression Blend,Listpicker,我使用的是列表选择器,但很难让设计正常工作。我已经包括了我所做的测试: <ControlTemplate x:Key="listpicker_style" TargetType="toolkit:ListPicker"> <StackPanel> <VisualStateManager.VisualStateGroups> <VisualStateGroup x:Name="Pic

我使用的是列表选择器,但很难让设计正常工作。我已经包括了我所做的测试:

 <ControlTemplate x:Key="listpicker_style" TargetType="toolkit:ListPicker">
        <StackPanel>
            <VisualStateManager.VisualStateGroups>
                <VisualStateGroup x:Name="PickerStates">
                    <VisualState x:Name="Normal"/>
                    <VisualState x:Name="Highlighted">
                        <Storyboard>
                            <ObjectAnimationUsingKeyFrames
                                Storyboard.TargetName="UserControl"
                                Storyboard.TargetProperty="Foreground"
                                Duration="0">
                                <DiscreteObjectKeyFrame
                                    Value="{StaticResource PhoneTextBoxForegroundBrush}"
                                    KeyTime="0"/>
                            </ObjectAnimationUsingKeyFrames>
                            <ObjectAnimationUsingKeyFrames
                                Storyboard.TargetName="Border"
                                Storyboard.TargetProperty="Background"
                                Duration="0">
                                <DiscreteObjectKeyFrame
                                    Value="{StaticResource PhoneTextBoxEditBackgroundColor}"
                                    KeyTime="0"/>
                            </ObjectAnimationUsingKeyFrames>
                            <ObjectAnimationUsingKeyFrames
                                Storyboard.TargetName="Border"
                                Storyboard.TargetProperty="BorderBrush"
                                Duration="0">
                                <DiscreteObjectKeyFrame
                                    Value="{StaticResource PhoneTextBoxEditBorderBrush}"
                                    KeyTime="0"/>
                            </ObjectAnimationUsingKeyFrames>
                        </Storyboard>
                    </VisualState>
                    <VisualState x:Name="Disabled">
                        <Storyboard>
                            <ObjectAnimationUsingKeyFrames
                                Storyboard.TargetName="Border"
                                Storyboard.TargetProperty="Background"
                                Duration="0">
                                <DiscreteObjectKeyFrame
                                    Value="{StaticResource TransparentBrush}"
                                    KeyTime="0"/>
                            </ObjectAnimationUsingKeyFrames>
                            <ObjectAnimationUsingKeyFrames
                                Storyboard.TargetName="Border"
                                Storyboard.TargetProperty="BorderBrush"
                                Duration="0">
                                <DiscreteObjectKeyFrame
                                    Value="{StaticResource PhoneDisabledBrush}"
                                    KeyTime="0"/>
                            </ObjectAnimationUsingKeyFrames>
                            <ObjectAnimationUsingKeyFrames
                                Storyboard.TargetName="UserControl"
                                Storyboard.TargetProperty="Foreground"
                                Duration="0">
                                <DiscreteObjectKeyFrame
                                    Value="{StaticResource PhoneDisabledBrush}"
                                    KeyTime="0"/>
                            </ObjectAnimationUsingKeyFrames>
                        </Storyboard>
                    </VisualState>
                </VisualStateGroup>
            </VisualStateManager.VisualStateGroups>
            <ContentControl
                Content="{TemplateBinding Header}"
                ContentTemplate="{TemplateBinding HeaderTemplate}"
                Foreground="{StaticResource PhoneSubtleBrush}"
                FontSize="{StaticResource PhoneFontSizeNormal}"
                HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                Margin="0 0 0 8"/>
            <Grid>
                <Rectangle Fill="#FFEAC726" HorizontalAlignment="Left" Height="52" Margin="0,0,-7,0" Stroke="Black" VerticalAlignment="Top" Width="83"/>
                <Rectangle Fill="#FF685B1F" HorizontalAlignment="Left" Height="9" Margin="0,0,-7,0" Stroke="Black" VerticalAlignment="Top" Width="83"/>
                <Rectangle Fill="#FF685B1F" HorizontalAlignment="Left" Height="9" Margin="0,43,-7,0" Stroke="Black" VerticalAlignment="Top" Width="83"/>
                <Border x:Name="Border"
                    Background="{TemplateBinding Background}"
                    BorderBrush="{TemplateBinding BorderBrush}"
                    BorderThickness="{TemplateBinding BorderThickness}" Opacity="0">
                    <UserControl x:Name="UserControl" Foreground="{TemplateBinding Foreground}" Margin="7,-3,-7,3">
                        <StackPanel>
                            <TextBlock x:Name="MultipleSelectionModeSummary" Margin="8 8 0 8" />
                            <Canvas x:Name="ItemsPresenterHost" MinHeight="46">
                                <ItemsPresenter x:Name="ItemsPresenter">
                                    <ItemsPresenter.RenderTransform>
                                        <TranslateTransform x:Name="ItemsPresenterTranslateTransform"/>
                                    </ItemsPresenter.RenderTransform>
                                </ItemsPresenter>
                            </Canvas>
                        </StackPanel>
                    </UserControl>
                </Border>
            </Grid>
        </StackPanel>
    </ControlTemplate>

基本上,我想要实现的是创建一个看起来像滚动条的listpicker。单击它时,滚动条将展开并显示整个选项。因此,我对使用全屏外观不感兴趣

我也做过其他类似的尝试,但效果很差,我使用设计好的用户控件作为动画的上下滚动条。但是listpicker的设计是不可能做到的

因此,我的问题是,是否有人使用usercontrols设计了listpicker,以便我可以覆盖它们,或者您是否可以指导我如何正确操作listpicker。我已经使用了blend、Expersion design、Illustrator和XAML,因此任何使用它们设计listpicker的方法都将不胜感激

视觉示例

所以这个想法是这样的:

这样,文本就在滚动条中,当您单击它时,滚动条将展开,其中包含一个列表,您可以滚动选择元素

用户控制

图片概述

所选项目:

单击该图元,将显示一个列表:


这就是listpicker的工作原理。我想把它设计成一个卷轴,要么从头开始,要么使用这个工具,这就是我要找的。但是,我没有成功地使扩展看起来很漂亮。

我已经尽我所能使它变得最简单。其思想如下:平移和缩放属性在状态之间设置动画,而其他属性(如高度等)则不设置动画。让我们创建如下布局:

 <StackPanel Width="500">
        <Grid x:Name="HeaderGrid" Height="100" Background="Red" Tapped="HeaderGrid_Tapped"/>
        <Grid VerticalAlignment="Top" x:Name="ContentGrid" Height="400" Background="BlanchedAlmond" RenderTransformOrigin="0.5,0">
            <Grid.RenderTransform>
                <CompositeTransform/>
            </Grid.RenderTransform>
            <ScrollViewer>
                <ItemsControl>
                    <ItemsControl.ItemTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding}" Tapped="TextBlock_Tapped"/>
                        </DataTemplate>
                    </ItemsControl.ItemTemplate>
                    <ItemsControl.Items>
                        <x:String>One</x:String>
                        <x:String>Two</x:String>
                        <x:String>Three</x:String>
                    </ItemsControl.Items>
                </ItemsControl>
            </ScrollViewer>
        </Grid>
        <Grid x:Name="BottomGrid" Height="100" Background="Red" Tapped="HeaderGrid_Tapped" RenderTransformOrigin="0.5,0.5">
            <Grid.RenderTransform>
                <CompositeTransform/>
            </Grid.RenderTransform>
        </Grid>
    </StackPanel>

现在,您可以在文本出现和消失时添加淡入淡出,并更改图像的颜色,等等。但这个想法已经解决。

您是否有一个直观的例子,说明您的目标是什么,您可以向人们指出?很难准确地理解你在描述中的意思。我确信它是可以做到的。所以你想在文字卷轴的区域内有一个可滚动的区域,当其中的一个项目被选中时,它会扩展以占据卷轴的更多区域?所以每个项目都是一个单独的卷轴?然后单击某个项目(滚动)时,滚动会展开以显示更多内容?对不起,朋友,我还不是100%清楚你想做什么哈哈。所以卷轴一开始只显示最小的内容,然后如果用户点击卷轴内容,卷轴会垂直打开,在其中提供一个列表选择器?是的,很抱歉没有时间跳回到这一点,目前我的工作任务太多了,但我会在今天的某个时候尝试返回。啊,看,我所想的甚至不需要codebehind等,只是坐在expanderview的定制样式模板内,所以你只需要将模板作为资源,然后在需要的地方将其作为静态资源点击。我会看一看,但是您可以将代码放在用户控件中,并在需要的地方使用它。事件必须更改,因为我有一个Silverlight应用程序(很抱歉没有指定它)。如果我将事件改为点击,则代码将起作用。但是视觉状态没有改变。代码现在放置在页面中,但visualstatemanager没有任何效果?
<VisualStateManager.VisualStateGroups>
        <VisualStateGroup x:Name="VisualStateGroup">
            <VisualStateGroup.Transitions>
                <VisualTransition GeneratedDuration="0:0:0.5"/>
            </VisualStateGroup.Transitions>
            <VisualState x:Name="Expanded"/>
            <VisualState x:Name="Collapsed">
                <Storyboard>
                    <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.ScaleY)" Storyboard.TargetName="ContentGrid" d:IsOptimized="True"/>
                    <DoubleAnimation Duration="0" To="-400" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateY)" Storyboard.TargetName="BottomGrid" d:IsOptimized="True"/>
                </Storyboard>
            </VisualState>
        </VisualStateGroup>
    </VisualStateManager.VisualStateGroups>
private void HeaderGrid_Tapped(object sender, TappedRoutedEventArgs e)
    {
        CheckState();
    }
    private void TextBlock_Tapped(object sender, TappedRoutedEventArgs e)
    {
        var value = (sender as FrameworkElement).DataContext;

        CheckState();
    }
    private void CheckState()
    {
        if ((ContentGrid.RenderTransform as CompositeTransform).ScaleY > 0)
            VisualStateManager.GoToState(this, "Collapsed", true);
        else
            VisualStateManager.GoToState(this, "Expanded", true);
    }