2011-10-17 3 views
1

크기 조정 때이처럼 보이는 광택 패널 효과를 만들어 LineSegments의 각도를 유지하기 위해 다각형을 그리는 방법은 다음과 같습니다WPF는 : 나는

<Window x:Class="Window1" 
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
     Title="Window1" Height="200" Width="300"> 
     <StackPanel Orientation="Vertical"> 
      <StackPanel.Background> 
       <DrawingBrush> 
        <DrawingBrush.Drawing> 
         <DrawingGroup> 
          <GeometryDrawing> 
           <GeometryDrawing.Geometry> 
            <RectangleGeometry Rect="0,0,1,1"></RectangleGeometry> 
           </GeometryDrawing.Geometry> 
           <GeometryDrawing.Brush> 
            <SolidColorBrush Opacity="0.5" Color="Blue" /> 
           </GeometryDrawing.Brush> 
          </GeometryDrawing> 
          <GeometryDrawing> 
           <GeometryDrawing.Geometry> 
            <PathGeometry> 
             <PathGeometry.Figures> 
              <PathFigureCollection> 
               <PathFigure IsClosed="True" StartPoint="0,0"> 
                <PathFigure.Segments> 
                 <PathSegmentCollection> 
                  <LineSegment Point="0.3,0" /> 
                  <LineSegment Point="0.2,1" /> 
                  <LineSegment Point="0,1" /> 
                  <LineSegment Point="0,0" /> 
                 </PathSegmentCollection> 
                </PathFigure.Segments> 
               </PathFigure> 
              </PathFigureCollection> 
             </PathGeometry.Figures> 
            </PathGeometry> 
           </GeometryDrawing.Geometry> 
           <GeometryDrawing.Brush> 
            <LinearGradientBrush StartPoint="0,0.5" EndPoint="1,0.5"> 
             <GradientStop Offset="0.0" Color="Transparent" /> 
             <GradientStop Offset="0.7" Color="#58FFFFFF" /> 
             <GradientStop Offset="1.0" Color="#AFFFFFFF" /> 
            </LinearGradientBrush> 
           </GeometryDrawing.Brush> 
          </GeometryDrawing> 
         </DrawingGroup> 
        </DrawingBrush.Drawing> 
       </DrawingBrush> 
      </StackPanel.Background> 
     </StackPanel> 
    </Window> 

:

Glossy panel

이는 XAML입니다 이제이 창 크기를 높이의 절반으로 조정하면 glint가 이전과 다른 각도로 기울어집니다.

Resized to half the height

위와 같은 코드가 작동하는 것으로 알고 있으며 제 질문은 다음과 같습니다. 크기 조정시 폴리곤 세그먼트의 각도가 유지되도록 같은 효과를 만들려면 어떻게해야합니까? 반값 크기 조정의 원하는 최종 결과는 다음과 같습니다

Desired resize to half the height: angle of the glint is preserved

답변

1

내가

<DrawingBrush Stretch="UniformToFill"> 
     ... 

트릭을 할해야한다고 생각.

+0

작동합니다! 나는 왼쪽 위 구석에 ​​비해 반짝 반짝 빛나는 해결책을 기대했지만, 그런 질문은하지 않았다. – SinkovecJ