1

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

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

它靠近此处描述的问题,但我有内部阴影......

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

请帮我修复它。谢谢!

 <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>
4

1 回答 1

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 -->

它似乎像您描述的那样工作,具有边框的内部阴影但不影响内部的元素。

于 2012-05-10T20:55:30.497 回答