2011-06-12 62 views
0

這是一種新的Silverlight,我怎樣才能使網格看起來像3D(有點像Silverlight進度條在視覺上突出)。我覺得我已經嘗試了一切,但我已經沒有想法了。任何人都可以給我一個可以做到這一點的代碼片段?使網格3d看起來

+0

你能解釋更多你想要什麼 – 2011-06-12 17:50:54

回答

2

您是否嘗試過使用DropShadowEffect

<data:DataGrid> 
    <data:DataGrid.Effect> 
    <DropShadowEffect /> 
    </data:DataGrid.Effect> 
    ... 
    ... 
</data:DataGrid> 

當然你也可以在其他控件上使用它。

創建凹陷的效果都是關於照明的錯覺。如果在元素周圍繪製邊框的頂部和左側爲深色,底部和右側爲淺色,則表示內容已沉入表面。切換陰影將會增加內容的效果。

這裏是一個小例子來說明

<UserControl x:Class="SilverlightApplication1.MainPage" 
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
     xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"   
     mc:Ignorable="d" 
     d:DesignHeight="300" d:DesignWidth="400" > 
    <Grid x:Name="LayoutRoot" Background="Lightgray"> 
    <Grid.ColumnDefinitions> 
     <ColumnDefinition /> 
     <ColumnDefinition /> 
     <ColumnDefinition /> 
    </Grid.ColumnDefinitions> 
    <Grid.RowDefinitions> 
     <RowDefinition /> 
     <RowDefinition /> 
     <RowDefinition /> 
    </Grid.RowDefinitions> 

    <StackPanel Grid.Row="1" Grid.Column="1" Orientation="Vertical"> 
     <!-- Sunken --> 
     <Grid Width="100" Height="25" Background="Wheat" Margin="0,5,0,0"> 
     <!-- Draw the 3d border --> 
     <Rectangle Height="1" Fill="DarkGray" HorizontalAlignment="Stretch" VerticalAlignment="Top" /> 
     <Rectangle Width="1" Fill="DarkGray" HorizontalAlignment="Left" VerticalAlignment="Stretch" /> 
     <Rectangle Height="1" Fill="White" HorizontalAlignment="Stretch" VerticalAlignment="Bottom" /> 
     <Rectangle Width="1" Fill="White" HorizontalAlignment="Right" VerticalAlignment="Stretch" /> 

     <!-- Put your content in this Grid --> 
     <Grid> 
      <TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" Text="Sunken" /> 
     </Grid> 
     </Grid> 

     <!-- Raised --> 
     <Grid Width="100" Height="25" Background="Wheat" Margin="0,5,0,0"> 
     <!-- Draw the 3d border --> 
     <Rectangle Height="1" Fill="White" HorizontalAlignment="Stretch" VerticalAlignment="Top" /> 
     <Rectangle Width="1" Fill="White" HorizontalAlignment="Left" VerticalAlignment="Stretch" /> 
     <Rectangle Height="1" Fill="DarkGray" HorizontalAlignment="Stretch" VerticalAlignment="Bottom" /> 
     <Rectangle Width="1" Fill="DarkGray" HorizontalAlignment="Right" VerticalAlignment="Stretch" /> 

     <!-- Put your content in this Grid --> 
     <Grid> 
      <TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" Text="Raised" /> 
     </Grid> 
     </Grid> 
    </StackPanel> 
    </Grid> 
</UserControl> 
+0

這確實有助於謝謝你,有沒有辦法給它一個凹陷效果看?否則我必須堅持這一點,但謝謝你的回覆:) – Jane 2011-06-12 18:38:44

+0

太棒了非常感謝你這正是我想要的:) – Jane 2011-06-12 21:26:14