VisualCollection クラス
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
Visual オブジェクトの順序付けられたコレクションを表します。
public ref class VisualCollection sealed : System::Collections::ICollection
public sealed class VisualCollection : System.Collections.ICollection
type VisualCollection = class
interface ICollection
interface IEnumerable
Public NotInheritable Class VisualCollection
Implements ICollection
- 継承
-
VisualCollection
- 実装
例
次の例では、 VisualCollection を作成し、それにメンバーを追加する方法を示します。
// Create a host visual derived from the FrameworkElement class.
// This class provides layout, event handling, and container support for
// the child visual objects.
public class MyVisualHost : FrameworkElement
{
// Create a collection of child visual objects.
private VisualCollection _children;
public MyVisualHost()
{
_children = new VisualCollection(this);
_children.Add(CreateDrawingVisualRectangle());
_children.Add(CreateDrawingVisualText());
_children.Add(CreateDrawingVisualEllipses());
// Add the event handler for MouseLeftButtonUp.
this.MouseLeftButtonUp += new System.Windows.Input.MouseButtonEventHandler(MyVisualHost_MouseLeftButtonUp);
}
' Create a host visual derived from the FrameworkElement class.
' This class provides layout, event handling, and container support for
' the child visual objects.
Public Class MyVisualHost
Inherits FrameworkElement
' Create a collection of child visual objects.
Private _children As VisualCollection
Public Sub New()
_children = New VisualCollection(Me)
_children.Add(CreateDrawingVisualRectangle())
_children.Add(CreateDrawingVisualText())
_children.Add(CreateDrawingVisualEllipses())
' Add the event handler for MouseLeftButtonUp.
AddHandler MouseLeftButtonUp, AddressOf MyVisualHost_MouseLeftButtonUp
End Sub
Note
完全なサンプルについては、「 DrawingVisuals サンプルを使用したヒット テスト」を参照してください。
注釈
VisualCollectionには暗黙的なコンテキスト アフィニティがあります。 プロシージャが所有するContainerVisualのコンテキストとは異なるコンテキストからVisualCollectionにアクセスしようとすると、例外がスローされます。
コンストラクター
| 名前 | 説明 |
|---|---|
| VisualCollection(Visual) |
VisualCollection クラスの新しいインスタンスを初期化します。 |
プロパティ
| 名前 | 説明 |
|---|---|
| Capacity |
VisualCollectionに含めることができる要素の数を取得または設定します。 |
| Count |
コレクション内の要素の数を取得します。 |
| IsReadOnly |
VisualCollectionが読み取り専用かどうかを示す値を取得します。 |
| IsSynchronized |
VisualCollectionへのアクセスが同期される (スレッド セーフ) かどうかを示す値を取得します。 |
| Item[Int32] |
VisualCollectionの 0 から始まるインデックスに格納されるVisualを取得または設定します。 |
| SyncRoot |
VisualCollectionへのアクセスを同期するために使用できるオブジェクトを取得します。 |
メソッド
| 名前 | 説明 |
|---|---|
| Add(Visual) |
VisualCollectionの末尾にVisualを追加します。 |
| Clear() |
VisualCollectionからすべての要素を削除します。 |
| Contains(Visual) | |
| CopyTo(Array, Int32) |
コレクション内の項目を、特定の配列インデックスから始まる配列にコピーします。 |
| CopyTo(Visual[], Int32) |
渡された Visual 配列に現在のコレクションをコピーします。 |
| Equals(Object) |
指定されたオブジェクトが現在のオブジェクトと等しいかどうかを判断します。 (継承元 Object) |
| GetEnumerator() |
VisualCollectionを反復処理できる列挙子を取得します。 |
| GetHashCode() |
既定のハッシュ関数として機能します。 (継承元 Object) |
| GetType() |
現在のインスタンスの Type を取得します。 (継承元 Object) |
| IndexOf(Visual) |
Visualの 0 から始まるインデックスを返します。 |
| Insert(Int32, Visual) |
指定したインデックス位置にある VisualCollection に要素を挿入します。 |
| MemberwiseClone() |
現在の Objectの簡易コピーを作成します。 (継承元 Object) |
| Remove(Visual) |
指定した Visual オブジェクトを VisualCollectionから削除します。 |
| RemoveAt(Int32) |
VisualCollection内の指定したインデックス位置にあるビジュアル オブジェクトを削除します。 |
| RemoveRange(Int32, Int32) |
VisualCollectionからビジュアル オブジェクトの範囲を削除します。 |
| ToString() |
現在のオブジェクトを表す文字列を返します。 (継承元 Object) |
明示的なインターフェイスの実装
| 名前 | 説明 |
|---|---|
| IEnumerable.GetEnumerator() |
このメンバーは WPF インフラストラクチャをサポートしており、コードから直接使用するためのものではありません。 このメンバーの説明については、 GetEnumerator()を参照してください。 |
拡張メソッド
| 名前 | 説明 |
|---|---|
| AsParallel(IEnumerable) |
クエリの並列化を有効にします。 |
| AsQueryable(IEnumerable) |
IEnumerable を IQueryableに変換します。 |
| Cast<TResult>(IEnumerable) |
IEnumerable の要素を指定した型にキャストします。 |
| OfType<TResult>(IEnumerable) |
指定した型に基づいて、IEnumerable の要素をフィルター処理します。 |