I define “DisplayHeight” in my App.xaml file here:
<Application.Resources>
<sys:Int32 x:Key="DisplayHeight">534</sys:Int32>
</Application.Resources>
I try to set my ListView Height here:
<Grid>
<ListView x:Name="myListView" Height="{StaticResource DisplayHeight}"/>
</Grid>
This results in the following exception:
{"'534' is not a valid value for property 'Height'."}
I don’t understand why this wouldn’t work. I can manually set the height to 534 and it works. Also, I read that a controls “Height” is an “Int32” so it shouldn’t be a type problem…
Heightis adouble, so you need to declare it as such if you want to useStaticResourcedirectly.Alternatively you could wrap it in a Binding which uses type converters: