Application.Properties 속성

정의

애플리케이션 범위 속성의 컬렉션을 가져옵니다.

public:
 property System::Collections::IDictionary ^ Properties { System::Collections::IDictionary ^ get(); };
public System.Collections.IDictionary Properties { get; }
member this.Properties : System.Collections.IDictionary
Public ReadOnly Property Properties As IDictionary

속성 값

애플리케이션 범위 속성이 들어 있는 IDictionary입니다.

예제

다음 예제에서는 어떻게 만들고 사용 하 여 애플리케이션 범위 속성을 사용 하 여 Properties입니다.

<Application x:Class="CSharp.App"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    StartupUri="MainWindow.xaml"
    Startup="App_Startup"
    >
</Application>
using System;
using System.Windows;

namespace CSharp
{
    public partial class App : Application
    {
        void App_Startup(object sender, StartupEventArgs e)
        {
            // Parse command line arguments for "/SafeMode"
            this.Properties["SafeMode"] = false;
            for (int i = 0; i != e.Args.Length; ++i)
            {
                if (e.Args[i].ToLower() == "/safemode")
                {
                    this.Properties["SafeMode"] = true;
                    break;
                }
            }
        }
    }
}

Imports System.Windows

Namespace VisualBasic
    Partial Public Class App
        Inherits Application
        Private Sub App_Startup(ByVal sender As Object, ByVal e As StartupEventArgs)
            ' Parse command line arguments for "/SafeMode"
            Me.Properties("SafeMode") = False
            Dim i As Integer = 0
            Do While i <> e.Args.Length
                If e.Args(i).ToLower() = "/safemode" Then
                    Me.Properties("SafeMode") = True
                    Exit Do
                End If
                i += 1
            Loop
        End Sub
    End Class
End Namespace
<Window x:Class="CSharp.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Loaded="MainWindow_Loaded"
    >
  <Grid>
  </Grid>
</Window>
using System;
using System.Windows;
using System.Windows.Controls;

namespace CSharp
{
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        void MainWindow_Loaded(object sender, EventArgs e)
        {
            // Check for safe mode
            if ((bool)Application.Current.Properties["SafeMode"] == true)
            {
                this.Title += " [SafeMode]";
            }
        }
    }
}

Imports System.Windows
Imports System.Windows.Controls

Namespace VisualBasic
    Partial Public Class MainWindow
        Inherits Window
        Public Sub New()
            InitializeComponent()
        End Sub

        Private Sub MainWindow_Loaded(ByVal sender As Object, ByVal e As EventArgs)
            ' Check for safe mode
            If CBool(Application.Current.Properties("SafeMode")) = True Then
                Me.Title &= " [SafeMode]"
            End If
        End Sub
    End Class
End Namespace

설명

Application 사전을 통해 노출 Properties 애플리케이션 범위 속성을 저장 하는 데 사용할 수 있는 합니다. 이렇게 하면 사용자 고유의 상태 코드를 작성할 필요 없이 스레드로부터 안전한 방식으로 모든 코드 AppDomain 간에 상태를 공유할 수 있습니다.

Properties 저장된 속성을 반환된 적절한 형식으로 변환해야 합니다.

속성은 Properties 스레드로부터 안전하며 모든 스레드에서 사용할 수 있습니다.

적용 대상

추가 정보