I`m doing some tests with Bindings and x:Bind and I found out some interesting thing.
XAML
<ListView Background="White" ItemsSource="{x:Bind ViewModel.CurrenciesViewModel.Currencies.Currencies}">
<ListView.ItemTemplate>
<DataTemplate x:DataType="model:Currency">
<StackPanel>
<TextBlock Foreground="Red" Text="1"/>
<TextBlock Foreground="Red" Text="{x:Bind Name}"/>
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
Ok so first x:Bind is to viewModel which have property CurrenciesViewModel (model name CurrencyListViewModel) which have property Currencies (model name CurrencyList) which have property Currencies and it is ObservableColletion
So this is working when I`m adding object like this
CurrenciesViewModel.Currencies.Currencies.Add(new Currency() { Name = "test" });
CurrenciesViewModel.Currencies.Currencies.Add(new Currency() { Name = "test2" });
But when I`m downloading my models by my DataProvider (simple rest with xml) with one method
Task<CurrencyList> GetCurrencyList();
So my first property CurrencyViewModel in my main ViewModel is like this
CurrenciesViewModel = new CurrencyListViewModel(await DataProvider.GetCurrencyList());
Then my listView is empty! I checked if my data is downloaded and yes it is... I changed x:Bind with Binding and everything is working.
I can copy-paste all classes if you want guys. But please tell me wtf ;)
The problem is how the default binding works in {x:Bind} vs {Binding}. In {x:Bind} the default binding is OneTime, but in {binding} the default Binding is OneWay. So even when you update the viewmodel the data will not change by default in x:binding.
To Resolve Change
<TextBlock Foreground="Red" Text="{x:Bind Name}"/>
To:
<TextBlock Foreground="Red" Text="{x:Bind Name Mode=OneWay} "/>