Felice Pollano
Felice Pollano

Reputation: 33262

Attribute {StaticResource resourcename} value is out of range

I have a button in a page defined as:

<Button Content="{StaticResource resourcename}" HorizontalAlignment="Left" VerticalAlignment="Top" Width="32" Height="32" >

and the resource "resourcename" is defined in the app as follow:

        <Grid x:Key="resourcename">
            <Path Fill="Black" Stretch="Fill" Data="M7.99799,14.26781 .....
        </Grid>

</Application.Resources>

When the application starts the following exception is raised:

Attribute {StaticResource resourcename} value is out of range.

I can't understand why, and BTW into the designer I can see the path correctly displayed. What I'm missing ?

Upvotes: 0

Views: 113

Answers (1)

Filip Skakun
Filip Skakun

Reputation: 31724

I have seen people trying to and complaining about Content being set from a UIElement stored in a resources collection. I would refrain from that approach - one problem being - a UIElement might only be a child of a single UIElement. A better approach might be to store a DataTemplate in resources and set that DataTemplate as a button's ContentTemplate.

Upvotes: 2

Related Questions