Spook
Spook

Reputation: 25927

Xamarin - update entry binding when unfocused

Is there a way to make the binding update only when entry is unfocused? I've bound entry to slider and it is hard to enter a value in entry, because binding kicks in and replaces the text in entry (for instance user writes "1", which gets immediately replaced by "1.00" and user cannot write anymore)

I've tried to set up the binding in the following way, without success:

<Entry (...)
    Text="{Binding Depth, Mode=TwoWay, Converter={StaticResource FloatToStringConverter}, UpdateSourceEventName=Unfocused}" />

Upvotes: 0

Views: 708

Answers (1)

Lucas Zhang
Lucas Zhang

Reputation: 18861

Refer to the following code

<StackLayout Padding="10, 0">
    <Slider x:Name="slider"  WidthRequest="300" HeightRequest="50" />

    <Entry  Text="{Binding Source={x:Reference slider},
                                Mode=OneWay,   
                                Path=Value,
                                Converter={StaticResource FloatToStringConverter}}" />


</StackLayout>

Upvotes: 0

Related Questions