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. 在幾何區域內的區域會顯示。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" />

套用裁剪區域之前的物件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. APointAnimation繪製橢圓形幾何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

適用於

另請參閱