内心阴影问题

时间:2012-05-10 20:36:00

标签: wpf silverlight xaml

我有这个代码来实现内部阴影。

不知何故,它包括TextBlock等等。我不需要它。我需要 ONLY INNER SHADOW

接近here描述的问题,但我有内心的影子......

所以我想保留内部阴影,但不要将其应用于字体等。

请帮我修理一下。谢谢!

 <DataTemplate x:Key="RSSItemTemplate">
            <Border Background="LightGray" BorderBrush="DarkGray" Margin="0,0,0,5" BorderThickness="1" ClipToBounds="True">
                <Border Background="Transparent" BorderBrush="Black" BorderThickness="1" Margin="-2">
                    <Border.Effect>
                        <DropShadowEffect ShadowDepth="0" BlurRadius="5" />
                    </Border.Effect>
                    <Grid>
                        <StackPanel Orientation="Vertical" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                            <Image>
                            </Image>
                            <StackPanel Orientation="Vertical" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                                <StackPanel Orientation="Horizontal" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                                    <TextBlock Text="{Binding Path=PublishDate}" Margin="0,0,5,0" />
                                    <TextBlock Text="{Binding Path=Title}"  TextWrapping="Wrap" />
                                </StackPanel>
                                <StackPanel Orientation="Horizontal" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                                    <TextBlock Text="{Binding Path=Description}" Margin="0,5,0,0" TextWrapping="Wrap" />
                                </StackPanel>
                            </StackPanel>
                        </StackPanel>
                    </Grid>
                </Border>
            </Border>
        </DataTemplate>
    </UserControl.Resources>

    <Grid>
        <ItemsControl x:Name="MainRoot"   ItemTemplate="{StaticResource RSSItemTemplate}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
    </Grid>

1 个答案:

答案 0 :(得分:2)

尝试像这样修改它:

<DataTemplate x:Key="RSSItemTemplate">
        <Border Background="LightGray" BorderBrush="DarkGray" Margin="0,0,0,5" BorderThickness="1" ClipToBounds="True">
                <Grid>
                    <Border Background="Transparent" BorderBrush="Black" BorderThickness="1" Margin="-2">
                        <Border.Effect>
                            <DropShadowEffect ShadowDepth="0" BlurRadius="5" />
                        </Border.Effect>
                    </Border>
                    <StackPanel Orientation="Vertical" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                        <Image>
                        </Image>
                        <StackPanel Orientation="Vertical" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                            <StackPanel Orientation="Horizontal" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                                <TextBlock Text="{Binding Path=PublishDate}" Margin="0,0,5,0" />
                                <TextBlock Text="{Binding Path=Title}"  TextWrapping="Wrap" />
                            </StackPanel>
                            <StackPanel Orientation="Horizontal" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                                <TextBlock Text="{Binding Path=Description}" Margin="0,5,0,0" TextWrapping="Wrap" />
                            </StackPanel>
                        </StackPanel>
                    </StackPanel>
                </Grid>
        </Border>
    </DataTemplate>
    <!-- the rest of the code here -->

它似乎按照你所描述的那样工作,具有边框的内部阴影但不影响其中的元素。