列表框项目文本颜色更改为点击事件后的当前重音颜色

时间:2012-08-21 04:47:49

标签: c# xml silverlight windows-phone-7

问题在这里说明: http://www.youtube.com/watch?v=EPyYIRvYhSI

我不知道是什么导致了这个问题,在ScrollView而不是ListBox中使用了相同的XML而没有任何问题,当我切换到ListBox时,问题出现了。

这是XML的一部分(实际上有114个网格,由于帖子的字符限制,我现在只展示其中的一些):

<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
    <ListBox Name="SV1"   FlowDirection="LeftToRight" Grid.Column="1" >
        <Grid Margin="0" Width="416">

            <Grid Name="grid1" Margin="0,0,0,9120" Tap="grid1_Tap" Grid.Column="2">
                <TextBlock Height="80" HorizontalAlignment="Left"  VerticalAlignment="Top" Margin="0,10,0,0" Text="1"  Width="87" TextAlignment="Center" FontSize="50" FontStretch="Normal" />
                <TextBlock Height="80" HorizontalAlignment="Right"  VerticalAlignment="Center" Margin="0,10,0,0" Text="1"  Width="55" FlowDirection="RightToLeft" FontSize="40" />
                <TextBlock Height="51" HorizontalAlignment="Right"  VerticalAlignment="Top" Margin="0,3,55,3" Text="XXXX"  Width="324" FlowDirection="RightToLeft" FontSize="40" />
                <TextBlock Height="40" HorizontalAlignment="Right"  VerticalAlignment="Bottom" Margin="0,3,55,3" Text="XXX"  Width="324" FlowDirection="RightToLeft" />

            </Grid>

            <Grid Name="grid2" Margin="0,80,0,9040" Tap="grid2_Tap" Grid.Column="2">
                <TextBlock Height="80" HorizontalAlignment="Left"  VerticalAlignment="Top" Margin="0,10,0,0" Text="2"  Width="87" TextAlignment="Center" FontSize="50" FontStretch="Normal" />
                <TextBlock Height="80" HorizontalAlignment="Right"  VerticalAlignment="Center" Margin="0,10,0,0" Text="2"  Width="55" FlowDirection="RightToLeft" FontSize="40" />
                <TextBlock Height="51" HorizontalAlignment="Right"  VerticalAlignment="Top" Margin="0,3,55,3" Text="XXXX"  Width="324" FlowDirection="RightToLeft" FontSize="40" />
                <TextBlock Height="40" HorizontalAlignment="Right"  VerticalAlignment="Bottom" Margin="0,3,55,3" Text="XXX"  Width="324" FlowDirection="RightToLeft" />

            </Grid>

            <Grid Name="grid3" Margin="0,160,0,8960" Tap="grid3_Tap" Grid.Column="2">
                <TextBlock Height="80" HorizontalAlignment="Left"  VerticalAlignment="Top" Margin="0,10,0,0" Text="50"  Width="87" TextAlignment="Center" FontSize="50" FontStretch="Normal" />
                <TextBlock Height="80" HorizontalAlignment="Right"  VerticalAlignment="Center" Margin="0,10,0,0" Text="3"  Width="55" FlowDirection="RightToLeft" FontSize="40" />
                <TextBlock Height="51" HorizontalAlignment="Right"  VerticalAlignment="Top" Margin="0,3,55,3" Text="XXXX"  Width="324" FlowDirection="RightToLeft" FontSize="40" />
                <TextBlock Height="40" HorizontalAlignment="Right"  VerticalAlignment="Bottom" Margin="0,3,55,3" Text="XXX"  Width="324" FlowDirection="RightToLeft" />

            </Grid>

            <Grid Name="grid4" Margin="0,240,0,8880" Tap="grid4_Tap" Grid.Column="2">
                <TextBlock Height="80" HorizontalAlignment="Left"  VerticalAlignment="Top" Margin="0,10,0,0" Text="77"  Width="87" TextAlignment="Center" FontSize="50" FontStretch="Normal" />
                <TextBlock Height="80" HorizontalAlignment="Right"  VerticalAlignment="Center" Margin="0,10,0,0" Text="4"  Width="55" FlowDirection="RightToLeft" FontSize="40" />
                <TextBlock Height="51" HorizontalAlignment="Right"  VerticalAlignment="Top" Margin="0,3,55,3" Text="XXXX"  Width="324" FlowDirection="RightToLeft" FontSize="40" />
                <TextBlock Height="40" HorizontalAlignment="Right"  VerticalAlignment="Bottom" Margin="0,3,55,3" Text="XXX"  Width="324" FlowDirection="RightToLeft" />

            </Grid>

            <Grid Name="grid5" Margin="0,320,0,8800" Tap="grid5_Tap" Grid.Column="2">
                <TextBlock Height="80" HorizontalAlignment="Left"  VerticalAlignment="Top" Margin="0,10,0,0" Text="106"  Width="87" TextAlignment="Center" FontSize="50" FontStretch="Normal" />
                <TextBlock Height="80" HorizontalAlignment="Right"  VerticalAlignment="Center" Margin="0,10,0,0" Text="5"  Width="55" FlowDirection="RightToLeft" FontSize="40" />
                <TextBlock Height="51" HorizontalAlignment="Right"  VerticalAlignment="Top" Margin="0,3,55,3" Text="XXXX"  Width="324" FlowDirection="RightToLeft" FontSize="40" />
                <TextBlock Height="40" HorizontalAlignment="Right"  VerticalAlignment="Bottom" Margin="0,3,55,3" Text="XXX"  Width="324" FlowDirection="RightToLeft" />

            </Grid>

            <Grid Name="grid6" Margin="0,400,0,8720" Tap="grid6_Tap" Grid.Column="2">
                <TextBlock Height="80" HorizontalAlignment="Left"  VerticalAlignment="Top" Margin="0,10,0,0" Text="128"  Width="87" TextAlignment="Center" FontSize="50" FontStretch="Normal" />
                <TextBlock Height="80" HorizontalAlignment="Right"  VerticalAlignment="Center" Margin="0,10,0,0" Text="6"  Width="55" FlowDirection="RightToLeft" FontSize="40" />
                <TextBlock Height="51" HorizontalAlignment="Right"  VerticalAlignment="Top" Margin="0,3,55,3" Text="XXXX"  Width="324" FlowDirection="RightToLeft" FontSize="40" />
                <TextBlock Height="40" HorizontalAlignment="Right"  VerticalAlignment="Bottom" Margin="0,3,55,3" Text="XXX"  Width="324" FlowDirection="RightToLeft" />

            </Grid>

            <Grid Name="grid7" Margin="0,480,0,8640" Tap="grid7_Tap" Grid.Column="2">
                <TextBlock Height="80" HorizontalAlignment="Left"  VerticalAlignment="Top" Margin="0,10,0,0" Text="151"  Width="87" TextAlignment="Center" FontSize="50" FontStretch="Normal" />
                <TextBlock Height="80" HorizontalAlignment="Right"  VerticalAlignment="Center" Margin="0,10,0,0" Text="7"  Width="55" FlowDirection="RightToLeft" FontSize="40" />
                <TextBlock Height="51" HorizontalAlignment="Right"  VerticalAlignment="Top" Margin="0,3,55,3" Text="XXXX"  Width="324" FlowDirection="RightToLeft" FontSize="40" />
                <TextBlock Height="40" HorizontalAlignment="Right"  VerticalAlignment="Bottom" Margin="0,3,55,3" Text="XXX"  Width="324" FlowDirection="RightToLeft" />

            </Grid>

            <Grid Name="grid8" Margin="0,560,0,8560" Tap="grid8_Tap" Grid.Column="2">
                <TextBlock Height="80" HorizontalAlignment="Left"  VerticalAlignment="Top" Margin="0,10,0,0" Text="177"  Width="87" TextAlignment="Center" FontSize="50" FontStretch="Normal" />
                <TextBlock Height="80" HorizontalAlignment="Right"  VerticalAlignment="Center" Margin="0,10,0,0" Text="8"  Width="55" FlowDirection="RightToLeft" FontSize="40" />
                <TextBlock Height="51" HorizontalAlignment="Right"  VerticalAlignment="Top" Margin="0,3,55,3" Text="XXXX"  Width="324" FlowDirection="RightToLeft" FontSize="40" />
                <TextBlock Height="40" HorizontalAlignment="Right"  VerticalAlignment="Bottom" Margin="0,3,55,3" Text="XXX"  Width="324" FlowDirection="RightToLeft" />

            </Grid>

            <Grid Name="grid9" Margin="0,640,0,8480" Tap="grid9_Tap" Grid.Column="2">
                <TextBlock Height="80" HorizontalAlignment="Left"  VerticalAlignment="Top" Margin="0,10,0,0" Text="187"  Width="87" TextAlignment="Center" FontSize="50" FontStretch="Normal" />
                <TextBlock Height="80" HorizontalAlignment="Right"  VerticalAlignment="Center" Margin="0,10,0,0" Text="9"  Width="55" FlowDirection="RightToLeft" FontSize="40" />
                <TextBlock Height="51" HorizontalAlignment="Right"  VerticalAlignment="Top" Margin="0,3,55,3" Text="XXXX"  Width="324" FlowDirection="RightToLeft" FontSize="40" />
                <TextBlock Height="40" HorizontalAlignment="Right"  VerticalAlignment="Bottom" Margin="0,3,55,3" Text="XXX"  Width="324" FlowDirection="RightToLeft" />

            </Grid>

            <Grid Name="grid10" Margin="0,720,0,8400" Tap="grid10_Tap" Grid.Column="2">
                <TextBlock Height="80" HorizontalAlignment="Left"  VerticalAlignment="Top" Margin="0,10,0,0" Text="208"  Width="87" TextAlignment="Center" FontSize="50" FontStretch="Normal" />
                <TextBlock Height="80" HorizontalAlignment="Right"  VerticalAlignment="Center" Margin="0,10,0,0" Text="10"  Width="55" FlowDirection="RightToLeft" FontSize="40" />
                <TextBlock Height="51" HorizontalAlignment="Right"  VerticalAlignment="Top" Margin="0,3,55,3" Text="XXXX"  Width="324" FlowDirection="RightToLeft" FontSize="40" />
                <TextBlock Height="40" HorizontalAlignment="Right"  VerticalAlignment="Bottom" Margin="0,3,55,3" Text="XXX"  Width="324" FlowDirection="RightToLeft" />

            </Grid>

            <Grid Name="grid11" Margin="0,800,0,8320" Tap="grid11_Tap" Grid.Column="2">
                <TextBlock Height="80" HorizontalAlignment="Left"  VerticalAlignment="Top" Margin="0,10,0,0" Text="221"  Width="87" TextAlignment="Center" FontSize="50" FontStretch="Normal" />
                <TextBlock Height="80" HorizontalAlignment="Right"  VerticalAlignment="Center" Margin="0,10,0,0" Text="11"  Width="55" FlowDirection="RightToLeft" FontSize="40" />
                <TextBlock Height="51" HorizontalAlignment="Right"  VerticalAlignment="Top" Margin="0,3,55,3" Text="XXXX"  Width="324" FlowDirection="RightToLeft" FontSize="40" />
                <TextBlock Height="40" HorizontalAlignment="Right"  VerticalAlignment="Bottom" Margin="0,3,55,3" Text="XXX"  Width="324" FlowDirection="RightToLeft" />

            </Grid>

            <Grid Name="grid12" Margin="0,880,0,8240" Tap="grid12_Tap" Grid.Column="2">
                <TextBlock Height="80" HorizontalAlignment="Left"  VerticalAlignment="Top" Margin="0,10,0,0" Text="235"  Width="87" TextAlignment="Center" FontSize="50" FontStretch="Normal" />
                <TextBlock Height="80" HorizontalAlignment="Right"  VerticalAlignment="Center" Margin="0,10,0,0" Text="12"  Width="55" FlowDirection="RightToLeft" FontSize="40" />
                <TextBlock Height="51" HorizontalAlignment="Right"  VerticalAlignment="Top" Margin="0,3,55,3" Text="XXXX"  Width="324" FlowDirection="RightToLeft" FontSize="40" />
                <TextBlock Height="40" HorizontalAlignment="Right"  VerticalAlignment="Bottom" Margin="0,3,55,3" Text="XXX"  Width="324" FlowDirection="RightToLeft" />

            </Grid>

            <Grid Name="grid13" Margin="0,960,0,8160" Tap="grid13_Tap" Grid.Column="2">
                <TextBlock Height="80" HorizontalAlignment="Left"  VerticalAlignment="Top" Margin="0,10,0,0" Text="249"  Width="87" TextAlignment="Center" FontSize="50" FontStretch="Normal" />
                <TextBlock Height="80" HorizontalAlignment="Right"  VerticalAlignment="Center" Margin="0,10,0,0" Text="13"  Width="55" FlowDirection="RightToLeft" FontSize="40" />
                <TextBlock Height="51" HorizontalAlignment="Right"  VerticalAlignment="Top" Margin="0,3,55,3" Text="XXXX"  Width="324" FlowDirection="RightToLeft" FontSize="40" />
                <TextBlock Height="40" HorizontalAlignment="Right"  VerticalAlignment="Bottom" Margin="0,3,55,3" Text="XXX"  Width="324" FlowDirection="RightToLeft" />

            </Grid>

            <Grid Name="grid14" Margin="0,1040,0,8080" Tap="grid14_Tap" Grid.Column="2">
                <TextBlock Height="80" HorizontalAlignment="Left"  VerticalAlignment="Top" Margin="0,10,0,0" Text="255"  Width="87" TextAlignment="Center" FontSize="50" FontStretch="Normal" />
                <TextBlock Height="80" HorizontalAlignment="Right"  VerticalAlignment="Center" Margin="0,10,0,0" Text="14"  Width="55" FlowDirection="RightToLeft" FontSize="40" />
                <TextBlock Height="51" HorizontalAlignment="Right"  VerticalAlignment="Top" Margin="0,3,55,3" Text="XXXX"  Width="324" FlowDirection="RightToLeft" FontSize="40" />
                <TextBlock Height="40" HorizontalAlignment="Right"  VerticalAlignment="Bottom" Margin="0,3,55,3" Text="XXX"  Width="324" FlowDirection="RightToLeft" />

            </Grid>

            <Grid Name="grid15" Margin="0,1120,0,8000" Tap="grid15_Tap" Grid.Column="2">
                <TextBlock Height="80" HorizontalAlignment="Left"  VerticalAlignment="Top" Margin="0,10,0,0" Text="262"  Width="87" TextAlignment="Center" FontSize="50" FontStretch="Normal" />
                <TextBlock Height="80" HorizontalAlignment="Right"  VerticalAlignment="Center" Margin="0,10,0,0" Text="15"  Width="55" FlowDirection="RightToLeft" FontSize="40" />
                <TextBlock Height="51" HorizontalAlignment="Right"  VerticalAlignment="Top" Margin="0,3,55,3" Text="XXXX"  Width="324" FlowDirection="RightToLeft" FontSize="40" />
                <TextBlock Height="40" HorizontalAlignment="Right"  VerticalAlignment="Bottom" Margin="0,3,55,3" Text="XXX"  Width="324" FlowDirection="RightToLeft" />

            </Grid>

            <Grid Name="grid16" Margin="0,1200,0,7920" Tap="grid16_Tap" Grid.Column="2">
                <TextBlock Height="80" HorizontalAlignment="Left"  VerticalAlignment="Top" Margin="0,10,0,0" Text="267"  Width="87" TextAlignment="Center" FontSize="50" FontStretch="Normal" />
                <TextBlock Height="80" HorizontalAlignment="Right"  VerticalAlignment="Center" Margin="0,10,0,0" Text="16"  Width="55" FlowDirection="RightToLeft" FontSize="40" />
                <TextBlock Height="51" HorizontalAlignment="Right"  VerticalAlignment="Top" Margin="0,3,55,3" Text="XXXX"  Width="324" FlowDirection="RightToLeft" FontSize="40" />
                <TextBlock Height="40" HorizontalAlignment="Right"  VerticalAlignment="Bottom" Margin="0,3,55,3" Text="XXX"  Width="324" FlowDirection="RightToLeft" />

            </Grid>

            <Grid Name="grid17" Margin="0,1280,0,7840" Tap="grid17_Tap" Grid.Column="2">
                <TextBlock Height="80" HorizontalAlignment="Left"  VerticalAlignment="Top" Margin="0,10,0,0" Text="282"  Width="87" TextAlignment="Center" FontSize="50" FontStretch="Normal" />
                <TextBlock Height="80" HorizontalAlignment="Right"  VerticalAlignment="Center" Margin="0,10,0,0" Text="17"  Width="55" FlowDirection="RightToLeft" FontSize="40" />
                <TextBlock Height="51" HorizontalAlignment="Right"  VerticalAlignment="Top" Margin="0,3,55,3" Text="XXXX"  Width="324" FlowDirection="RightToLeft" FontSize="40" />
                <TextBlock Height="40" HorizontalAlignment="Right"  VerticalAlignment="Bottom" Margin="0,3,55,3" Text="XXX"  Width="324" FlowDirection="RightToLeft" />

            </Grid>

            <Grid Name="grid18" Margin="0,1360,0,7760" Tap="grid18_Tap" Grid.Column="2">
                <TextBlock Height="80" HorizontalAlignment="Left"  VerticalAlignment="Top" Margin="0,10,0,0" Text="293"  Width="87" TextAlignment="Center" FontSize="50" FontStretch="Normal" />
                <TextBlock Height="80" HorizontalAlignment="Right"  VerticalAlignment="Center" Margin="0,10,0,0" Text="18"  Width="55" FlowDirection="RightToLeft" FontSize="40" />
                <TextBlock Height="51" HorizontalAlignment="Right"  VerticalAlignment="Top" Margin="0,3,55,3" Text="XXXX"  Width="324" FlowDirection="RightToLeft" FontSize="40" />
                <TextBlock Height="40" HorizontalAlignment="Right"  VerticalAlignment="Bottom" Margin="0,3,55,3" Text="XXX"  Width="324" FlowDirection="RightToLeft" />

            </Grid>

            <Grid Name="grid19" Margin="0,1440,0,7680" Tap="grid19_Tap" Grid.Column="2">
                <TextBlock Height="80" HorizontalAlignment="Left"  VerticalAlignment="Top" Margin="0,10,0,0" Text="305"  Width="87" TextAlignment="Center" FontSize="50" FontStretch="Normal" />
                <TextBlock Height="80" HorizontalAlignment="Right"  VerticalAlignment="Center" Margin="0,10,0,0" Text="19"  Width="55" FlowDirection="RightToLeft" FontSize="40" />
                <TextBlock Height="51" HorizontalAlignment="Right"  VerticalAlignment="Top" Margin="0,3,55,3" Text="XXXX"  Width="324" FlowDirection="RightToLeft" FontSize="40" />
                <TextBlock Height="40" HorizontalAlignment="Right"  VerticalAlignment="Bottom" Margin="0,3,55,3" Text="XXX"  Width="324" FlowDirection="RightToLeft" />

            </Grid>
        </Grid>
    </ListBox>
</Grid>

1 个答案:

答案 0 :(得分:2)

这是因为您在列表框中有一个网格作为单个列表框项。因此,当您点击列表框时,内部网格显然会被选中。默认情况下,列表框中的选定项目会突出显示。