2009-04-28 26 views

答えて

38

が含まれ、あなたがFreeze属性を使用XMLネームスペースhttp://schemas.microsoft.com/winfx/2006/xaml/presentation/optionsで定義されています。

次の例では、SolidColorBrushがページリソースとして宣言され、フリーズしています。次に、ボタンの背景を設定するために使用されます。

<Page 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:po="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    mc:Ignorable="po"> 

    <Page.Resources> 
    <!-- This brush is frozen --> 
    <SolidColorBrush x:Key="MyBrush" po:Freeze="True" Color="Red" /> 
    </Page.Resources> 

    <!-- Use the frozen brush --> 
    <Button Background="{StaticResource MyBrush}">Click Me</Button> 

</Page> 

出典:Freezable Objects Overview

+2

最後の属性は 'mc:Ignorable =" po "'でなくてはなりませんか? – CodeNaked

+0

@ CodeNaked、私はあなたが正しいと信じています。編集されました。 –

9

あなたのXAML名前空間宣言にこれを追加します。

xmlns:po="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options" 
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
mc:Ignorable="po" 

を、その後、あなたの凍結可能なオブジェクトには、マークアップで宣言さFreezableオブジェクトをフリーズするには、この属性

po:Freeze="True" 
+0

'MC' の名前空間から来るのでしょうか? –

+0

ああ、私はそれを逃したと思う。今すぐ修正しました。 – Botz3000

関連する問題