I'm porting code that was using the {Binding} markup extension to the more modern {x:Bind} and face the following error when building my project:
Cannot directly bind type 'System.Double' to 'System.Single'. Use a cast, converter or function binding to change the type
My code is the following:
<Grid>
<TextBlock Text="Rotation"
Rotation="{x:Bind slider.Value}"
x:DefaultBindMode="OneWay"
FontWeight="Bold"
FontSize="36"
HorizontalAlignment="Center"
VerticalAlignment="Center" />
<Slider x:Name="slider"
Maximum="360"
VerticalAlignment="Stretch" />
</Grid>
I can see that Slider.Value is defined as a Double where TextBlock.Rotation is a float. What's the correct way to cast slider.Value to a Single?
I tried casting like this {x:Bind (x:Single)slider.Value} but the build then fails with the error:
Invalid binding path '(x:Single)slider.Value' : Type 'x:Single' not found.