相关疑难解决方法(0)

WPF:ItemsControl上的交替颜色?

如何在ItemsControl上获得交替颜色?我将AlternationCount设置为2,但ItemsControl.AlternationIndex属性始终返回0.

        <ItemsControl ItemsSource="{Binding}" AlternationCount="2">
            <ItemsControl.Resources>
                <Style x:Key="FooBar" TargetType="Grid">
                    <Style.Triggers>
                        <Trigger Property="ItemsControl.AlternationIndex" Value="0">
                            <Setter Property="Background" Value="Blue"/>
                        </Trigger>
                        <Trigger Property="ItemsControl.AlternationIndex" Value="1">
                            <Setter Property="Background" Value="Red"/>
                        </Trigger>
                    </Style.Triggers>
                </Style>
            </ItemsControl.Resources>
            <ItemsControl.ItemTemplate>
                <DataTemplate>
                    <Grid Margin="0,0,0,10" Style="{StaticResource FooBar}">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="25" />
                            <ColumnDefinition Width="100" />
                            <ColumnDefinition Width="100" />
                            <ColumnDefinition Width="100" />
                            <ColumnDefinition Width="100" />
                            <ColumnDefinition Width="100" />
                            <ColumnDefinition Width="100" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions >
                            <RowDefinition Height="Auto" />
                            <!--<RowDefinition Height="Auto" />-->
                        </Grid.RowDefinitions>

                        <CheckBox IsChecked="{Binding Checked, UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Center" />
                        <Label Grid.Column="1" Content="{Binding CompanyName}" />
                        <Label Grid.Column="2" …
Run Code Online (Sandbox Code Playgroud)

wpf styles itemscontrol

33
推荐指数
2
解决办法
2万
查看次数

Windows Phone 8.1中ListView中行的交替颜色

我创建了一个Windows Phone 8.1运行时应用程序.

我正在使用ListView控件.

我想交替每个背景行颜色.

搜索后我发现此链接是之前的答案.

但这会给标记带来错误.一方面,没有'AlternationCount'属性.我假设这是因为它不是SilverLight而是RT?

如果有人可以给我发送链接,因为我正在寻找一个简单的例子.更好的是一个简单的代码示例将不胜感激.

listview listviewitem windows-runtime windows-phone-8.1

11
推荐指数
2
解决办法
3022
查看次数