xaml style as static resource how to have error on compilation rather than execution if not exist

20 Views Asked by At

Well, all is in the title.

In your App.xaml, you declare the style as follow

<Style x:Key="MyCustomLabelStyle" TargetType="Label">
    <Setter Property="TextColor" Value="Red"/>
</Style>

In your xaml page, you declare a label with the name of the style but no luck you miss spell the x:Key, for exemple

<Label Style="{StaticResource MyCustomLabelStyl}"/>

instead of

<Label Style="{StaticResource MyCustomLabelStyle}"/>

if the style is not present or is present but with an other name, the app throw an exception at runtime. That's perfectly normal.

My question is : is there a way to have a compilation error when you miss spell a style key, like with compilated binding when you use x:DataType.

Thanks for your time and have a good day.

0

There are 0 best solutions below