CustomContentState 클래스

정의

CustomContentState 를 사용하면 각 후속 탐색에 대한 원본 콘텐츠를 다시 로드하지 않고도 원본 콘텐츠의 여러 상태를 탐색할 수 있습니다.

public ref class CustomContentState abstract
[System.Serializable]
public abstract class CustomContentState
public abstract class CustomContentState
[<System.Serializable>]
type CustomContentState = class
type CustomContentState = class
Public MustInherit Class CustomContentState
상속
CustomContentState
특성

예제

다음은 재정의하는 CustomContentState 구현의 예입니다 JournalEntryName.

using System;
using System.Windows.Controls;
using System.Windows.Navigation;
[Serializable]
public class MyCustomContentState : CustomContentState
{
    string dateCreated;
    TextBlock dateTextBlock;

    public MyCustomContentState(string dateCreated, TextBlock dateTextBlock)
    {
        this.dateCreated = dateCreated;
        this.dateTextBlock = dateTextBlock;
    }

    public override string JournalEntryName
    {
        get
        {
            return "Journal Entry " + this.dateCreated;
        }
    }

    public override void Replay(NavigationService navigationService, NavigationMode mode)
    {
        this.dateTextBlock.Text = this.dateCreated;
    }
}

Imports System.Windows.Controls
Imports System.Windows.Navigation
<Serializable>
Public Class MyCustomContentState
    Inherits CustomContentState
    Private dateCreated As String
    Private dateTextBlock As TextBlock

    Public Sub New(ByVal dateCreated As String, ByVal dateTextBlock As TextBlock)
        Me.dateCreated = dateCreated
        Me.dateTextBlock = dateTextBlock
    End Sub

    Public Overrides ReadOnly Property JournalEntryName() As String
        Get
            Return "Journal Entry " & Me.dateCreated
        End Get
    End Property

    Public Overrides Sub Replay(ByVal navigationService As NavigationService, ByVal mode As NavigationMode)
        Me.dateTextBlock.Text = Me.dateCreated
    End Sub
End Class

설명

기본적으로 NavigationService 콘텐츠 개체의 인스턴스는 탐색 기록에 저장하지 않습니다. 대신 탐색 NavigationService 기록을 사용하여 탐색할 때마다 콘텐츠 개체의 새 인스턴스를 만듭니다. 이 동작은 많은 수와 많은 콘텐츠가 탐색될 때 과도한 메모리 소비를 방지하도록 설계되었습니다. 따라서 콘텐츠의 상태는 한 탐색에서 다음 탐색으로 기억되지 않습니다. 그러나 WPF 콘텐츠의 탐색 기록 항목과 사용자 지정 상태의 조각을 연결하는 기능을 제공합니다.

탐색 기록 항목과 연결된 사용자 지정 상태는 에서 CustomContentState파생되는 클래스여야 합니다. 다음 기술 중 하나를 사용하여 개체를 탐색 기록 항목과 연결 CustomContentState 합니다.

메모

AddBackEntry 메서드를 호출하는 경우 탐색 이벤트를 처리하거나 구현IProvideCustomContentState해야 합니다.

탐색 기록 항목을 탐색할 때 WPF 사용자 지정 CustomContentState 개체가 연결되어 있는지 확인합니다. 이 경우 사용자 지정 Replay 개체가 이전 탐색에서 기억한 상태를 적용할 수 있도록 호출 CustomContentState 합니다.

사용자 지정 CustomContentState 클래스를 재정 JournalEntryName 의하여 개체가 연결된 탐색 기록 항목 CustomContentState 에 표시되는 이름을 변경할 수 있습니다. 반환되는 JournalEntryName 값은 다양한 탐색기(브라우저 NavigationWindow또는 Frame)의 탐색 UI에서 볼 수 있습니다.

파생 CustomContentState 되는 클래스는 serialize 가능해야 합니다. 즉, 최소한 확대 SerializableAttribute하고 필요에 따라 구현 ISerializable해야 합니다.

Important

사용자 지정 콘텐츠 상태에 정보를 저장하는 경우 메모리에 콘텐츠를 유지하지 않으려는 경우 상태를 기억하고 있는 페이지의 인스턴스에 대한 참조를 저장할 수 없습니다. 이렇게 하면 WPF 페이지 인스턴스를 해제할 수 없으며 기본 탐색 기록 동작의 목적이 무효화됩니다. 이 작업을 수행해야 하는 경우 대신 사용하는 KeepAlive 것이 좋습니다.

생성자

Name Description
CustomContentState()

CustomContentState 클래스의 새 인스턴스를 초기화합니다.

속성

Name Description
JournalEntryName

탐색 기록에 저장된 콘텐츠의 이름을 가져옵니다. 값 JournalEntryName 은 브라우저 NavigationWindow탐색 UI에서 Frame표시됩니다.

메서드

Name Description
Equals(Object)

지정된 개체가 현재 개체와 같은지 여부를 확인합니다.

(다음에서 상속됨 Object)
GetHashCode()

기본 해시 함수로 사용됩니다.

(다음에서 상속됨 Object)
GetType()

현재 인스턴스의 Type 가져옵니다.

(다음에서 상속됨 Object)
MemberwiseClone()

현재 Object단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
Replay(NavigationService, NavigationMode)

탐색이 발생할 때 콘텐츠 부분에 상태를 다시 적용하기 위해 호출됩니다.

ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)

적용 대상

추가 정보