shenku
shenku

Reputation: 12458

Why can I not access some properties on WPF controls?

I am trying to apply styles to a control in WPF. And have noticed that some properties available in code behind arent available in XAML?

Why is this?

And can you help me with the following example:

<Style TargetType="RichTextBox">
        <Setter Property="VerticalScrollBarVisibility" Value="Auto"></Setter>
        <Setter Property="Background" Value="WhiteSmoke"></Setter>
        <Setter Property="Foreground" Value="#515151"></Setter>
        <Setter Property="Document.PageWidth" Value="300"></Setter>
    </Style>

When trying to apply the PageWidth to the Document of the control, I get an exception that it is not accessible?

Thanks.

Upvotes: 0

Views: 117

Answers (2)

user1239656
user1239656

Reputation: 16

You can set styles for the Dependency Property alone

Upvotes: 0

brunnerh
brunnerh

Reputation: 185117

Setter.Property is not a path, you cannot use it to set "properties of properties".

Upvotes: 1

Related Questions