DataType in .xaml

Good morning,

Which data type should I use for the HeightRequest to prevent binding failures during compilation?

                    <buttons:SfButton

                       x:Name="btn2"

                       Grid.Row="{OnIdiom Phone=0,

                                          Tablet=0}"

                       Grid.Column="{OnIdiom Phone=3,

                                             Tablet=2}"

                       Command="{Binding ScheduleCommand}"

                       FontSize="Medium"

                       HeightRequest="{Binding WidthRequest, Source={x:Reference btn1}, x:DataType=buttons:SfButton}"

                       ImageAlignment="Top"

                       ImageSize="60"

                       IsEnabled="{Binding IsNotBusy}"

                       ShowIcon="True"

                       Text="{x:Static res:AppResource.verlof}">

                       <buttons:SfButton.ImageSource>

                           <FontImageSource FontFamily="FASolid" Glyph="{StaticResource calendar-days}" />

                       </buttons:SfButton.ImageSource>

                   </buttons:SfButton>


Regards,

Thijs van Rijswijk


1 Reply

HK Hemalatha Kondappakumareshan Syncfusion Team December 23, 2025 07:02 AM UTC

Hi Thijs van Rijswijk,


Thank you for reaching out to us. We have reviewed your query. As you mentioned, you are trying to bind the HeightRequest of one SfButton to the WidthRequest of another, and you’re unsure which data type should be used to avoid compilation failures.

Since both HeightRequest and WidthRequest are already of type double, the binding itself is correct. The issue occurs because x:DataType should not be used with a binding that references another element via x:Reference. Removing x:DataType resolves the compiletime binding error.


 <buttons:SfButton x:Name="btn2"

                   Grid.Row="{OnIdiom Phone=0,  Tablet=0}"

                   Grid.Column="{OnIdiom Phone=3, Tablet=2}"

                   Command="{Binding ScheduleCommand}"

                   FontSize="Medium"

                   HeightRequest="{Binding Source={x:Reference btn1}, Path=WidthRequest}"

                   ImageAlignment="Top"

                   ImageSize="60"

                   IsEnabled="{Binding IsNotBusy}"

                   ShowIcon="True"

                   Text="{x:Static res:AppResource.verlof}">

    <buttons:SfButton.ImageSource>

        <FontImageSource FontFamily="FASolid" Glyph="{StaticResource calendar-days}"/>

    </buttons:SfButton.ImageSource>

</buttons:SfButton>


This works because the binding simply connects one double property to another, and removing x:DataType avoids the compiletime binding conflict.

Please let us know if you need any further assistance or have additional questions.


Regards,

Hemalatha K


Loader.
Up arrow icon