Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 91519

2 way binding between slider and entry

$
0
0

Hey guys, so I'm attempting to do something I would assume is fairly simple. Basically I have a Slider and an Entry next to each other. When you slide the slider, I want the Entry field to update with a dollar value. For instance instead of displaying "900" I want it to display "$900". If the slider is a negative value, say -400, I want it to display "($400)". Our users know the notation of the parenthesis denoting a negative number. This all works with my custom value converter. Now the problem comes in when trying to type in the text box and updating the slider. So if I type in "$900", I would like the slider to re-position itself to the correct position. This part KIND of works, I've posted a screenshot giving you an idea of how it looks.

The only hiccup here is when I type in "$10,000" for some reason, the text auto corrects it self to "$900". The slider is in the correct spot, but I'm not sure why I can't enter in the EXACT value I want to enter in. See Screen shot.

Xaml Code:

        <Label Text="Long Term Gains / (Losses)" Grid.Row="8" Grid.Column="0" />
        <Slider x:Name="sliderLongTermGainsOrLosses" Minimum="-15000" Maximum="15000" Value="{Binding LongTermGainsOrLosses, Mode=TwoWay}" Grid.Row="9" Grid.Column="0"/>
        <Entry Text="{Binding LongTermGainsOrLosses, Mode=TwoWay, Converter={StaticResource decimalToCurrencyStringConverter}}" Keyboard="Numeric" Grid.Row="9" Grid.Column="1" />


Viewing all articles
Browse latest Browse all 91519

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>