UIElement.Clip UIElement.Clip UIElement.Clip UIElement.Clip Property

定義

取得或設定用來定義項目內容外框的幾何。Gets or sets the geometry used to define the outline of the contents of an element. 這是相依性屬性。This is a dependency property.

public:
 property System::Windows::Media::Geometry ^ Clip { System::Windows::Media::Geometry ^ get(); void set(System::Windows::Media::Geometry ^ value); };
public System.Windows.Media.Geometry Clip { get; set; }
member this.Clip : System.Windows.Media.Geometry with get, set
Public Property Clip As Geometry

屬性值

用於裁剪區域大小的幾何。The geometry to be used for clipping area sizing. 預設值為 null GeometryThe default is a null Geometry.

範例

這個範例示範如何定義架構專案的Clip區域。This example shows how to define a framework element's Clip region. 若要定義剪輯, 請使用Geometry (例如EllipseGeometry ) 來設定元素的Clip屬性。To define a clip, use a Geometry (for example, an EllipseGeometry to set the element's Clip property. 只有 geometry 區域內的區域才會顯示。Only the area that is within the region of the geometry will be visible.

下列範例顯示Image沒有定義之裁剪區域的元素。The following example shows an Image element without a defined clip region. 因為未定義任何剪輯區域, 所以會顯示整個影像。Because no clip region is defined, the entire image is displayed.

<Image Source="sampleImages\Waterlilies.jpg" 
  Width="200" Height="150" HorizontalAlignment="Left" />

套用![裁剪區域前的物件]套用(~/add/media/mil-task-clip-region-noclip.png "裁剪區域前的物件")An object before applying a clip region
沒有剪輯區域的影像Image with No Clip Region

在下一個範例中, 會建立相同的映射, 不同之處在于它有定義的裁剪區域。In the next example, an identical Image is created, except that it has a defined clip region. 只會顯示在區域EllipseGeometry內的影像部分。Only the part of the image that is within the area the EllipseGeometry will be displayed.

<Image 
  Source="sampleImages\Waterlilies.jpg" 
  Width="200" Height="150" HorizontalAlignment="Left">
  <Image.Clip>
    <EllipseGeometry
      RadiusX="100"
      RadiusY="75"
      Center="100,75"/>
  </Image.Clip>
</Image>

裁剪的物件A clipped object
具有橢圓形裁剪區域的影像Image with an Elliptical Clip Region

下列範例示範如何以動畫顯示架構專案的Clip區域。The following example shows how animate a framework element's Clip region. 在此範例中, EllipseGeometry是用來定義Image元素的橢圓形剪輯區域。In this example, an EllipseGeometry is used to define an elliptical clip region for an Image element. PointAnimation橢圓形 geometry 的Center屬性從 (0, 0) 繪製到 (200, 150) 的動畫。A PointAnimation animates the ellipse geometry's Center property from (0, 0) to (200, 150). 動畫會在載入影像並無限期重複後開始播放。The animation starts playing after the image is loaded and repeats indefinitely.

<Image
  Source="sampleImages\Waterlilies.jpg" 
  Width="200" Height="150" HorizontalAlignment="Left">
  <Image.Clip>
    <EllipseGeometry x:Name="MyEllipseGeometry1"
      RadiusX="100"
      RadiusY="75"
      Center="100,75"/>
  </Image.Clip>
  <Image.Triggers>
    <EventTrigger RoutedEvent="Image.Loaded">
      <BeginStoryboard>
        <Storyboard>
          <PointAnimation 
            Storyboard.TargetName="MyEllipseGeometry1" 
            Storyboard.TargetProperty="(EllipseGeometry.Center)"
            From="0,0" To="200,150" Duration="0:0:3" RepeatBehavior="Forever" 
            AutoReverse="True" />
          </Storyboard>
      </BeginStoryboard>
    </EventTrigger>
  </Image.Triggers>
</Image> 

如需完整範例, 請參閱剪輯區域範例For the full sample, see the Clip Region Sample.

備註

幾何外的元素會在轉譯的版面配置中以視覺方式裁剪。Elements outside the geometry will be visually clipped in the rendered layout. 幾何不一定要是矩形。The geometry does not have to be rectangular.

相依性屬性資訊Dependency Property Information

識別碼欄位Identifier field ClipProperty
中繼資料屬性設定為trueMetadata properties set to true None

適用於

另請參閱