2012-12-16 4 views
0

내 프로젝트 요구 사항은 그리드 배경 이미지와 같으며 검은 색으로 위쪽과 아래쪽에 그라데이션을 적용하려고합니다. 친절하게 도와서 어떻게 성취 할 수 있을까요? 아래Silverlight Grid 그래디언트가있는 배경 이미지

내 XAML :

<Grid Grid.Row="0" HorizontalAlignment="Stretch" Height="190" VerticalAlignment="Stretch" ShowGridLines="False" Margin="0,2,0,0"> 
    <Grid.Background> 
      <ImageBrush Stretch="UniformToFill" Opacity="0.6"> 
        <ImageBrush.ImageSource> 
         <BitmapImage CreateOptions="BackgroundCreation" UriSource="{Binding Banner}"></BitmapImage> 
        </ImageBrush.ImageSource> 
       </ImageBrush> 
    </Grid.Background> 
    ..... 
</Grid 

답변

0

이 내부에 다른 표를 만듭니다. 이 새로운 그리드에서 세 개의 행을 작성하십시오. 처음과 마지막 행에는 그래디언트가있는 사각형이 있어야합니다. 다음과 같은 내용 :

<Grid Grid.Row="0" HorizontalAlignment="Stretch" Height="190" VerticalAlignment="Stretch" ShowGridLines="False" Margin="0,2,0,0"> 
    <Grid.Background> 
     <ImageBrush Stretch="UniformToFill" Opacity="0.6"> 
       <ImageBrush.ImageSource> 
        <BitmapImage CreateOptions="BackgroundCreation" UriSource="{Binding Banner}"></BitmapImage> 
       </ImageBrush.ImageSource> 
      </ImageBrush> 
     </Grid.Background> 
     <Grid Grid.ColumnSpan="..." Grid.RowSpan="..."> 
      <Grid.RowDefinitions> 
       <RowDefinition Height="25"/> 
       <RowDefinition Height="*"/> 
       <RowDefinition Height="25"/> 
      </Grid.RowDefinitions> 
      <Rectangle Grid.Row="0"> 
       <Rectangle.Fill> 
        ... 
       </Rectangle.Fill> 
      </Rectangle> 
      <Rectangle Grid.Row="2"> 
       <Rectangle.Fill> 
        ... 
       </Rectangle.Fill> 
      </Rectangle> 
     </Grid> 
</Grid 
0
<Grid.Background> 
     <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> 
      <GradientStop Color="Black" Offset="0"/> 
      <GradientStop Color="Gray" Offset="1"/> 
     </LinearGradientBrush> 
    </Grid.Background> 

변경 당신이 원하는 무엇 색상의 값. 그 트릭을해야합니다.