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

Set a Picker.SelectedItem on page startup

$
0
0

I have this piece of code

<Picker x:Name="CategoryPicker" 
ItemsSource="{Binding Categories, Mode=TwoWay}"
SelectedItem="{Binding Path= RequestItem.Category, Mode=TwoWay}" 
HorizontalOptions="FillAndExpand"
Title="Escolha uma Categoria"
SelectedIndexChanged="OnSelectedIndexChanged"
ItemDisplayBinding="{Binding Name}"
Margin="10,20,10,0">

I'm saving an item, and when I save it, it goes to a list of items... If I want to change one of those items, I need to set the picker to the value stored in RequestItem.Category...
Since I'm binding the SelectedItem property It should automaticaly set the value of it rigth?

I've also tryed to do this on my Page constructor with this
CategoryPicker.SelectedItem = estimate?.Category;
and this
CategoryPicker.SelectedIndex = 0;
If I set a breakpoint rigth after this, CategoryPicker.SelectedIndex is equal to -1... It doesn't change to 0...

None of those seems to work... What am I doing wrong?


Viewing all articles
Browse latest Browse all 77050

Trending Articles



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