We are developing a Windows Phone application (CurrencyExchange) and there is a page that includes a textbox and a listbox. ListBox's itemsource is it's viewmodel's property type of observable collection. Textbox's textchange event is changing observable collection's all items but when observable changing and trying to bind listbox's items, the page is locking. I have seen a customobservable collection named Fastobservablecollection that is not running in viewmodel because it is using DispatcherObject and Dispatcherprioty that can't use in viewmodel. Are there any alternative that better than ObservableCollection?
List<Currency> newList = new List<Currency>(CurrencyConversions.ToList());
foreach (var item in newList)
{
Double result;
if (Double.TryParse(AmountPhone, NumberStyles.Any, new System.Globalization.CultureInfo("tr-TR"), out result))
item.CalculatedValue = Math.Round(result * (Direction == "0" ? item.ConversionRateSell : item.ConversionRateBuy), 2);
else
item.CalculatedValue = 0;
}
CurrencyConversions = new ObservableCollection<Currency>(newList);
or
List<Currency> newList = new List<Currency>();
foreach (var item in CurrencyConversions)
{
Double result;
if (Double.TryParse(AmountPhone, NumberStyles.Any, new System.Globalization.CultureInfo("tr-TR"), out result))
item.CalculatedValue = Math.Round(result * (Direction == "0" ? item.ConversionRateSell : item.ConversionRateBuy), 2);
else
item.CalculatedValue = 0;
newList.Add(item);
}
CurrencyConversions = new ObservableCollection<Currency>(newList);
Thanks.
With SmartCollection
List<Currency> newList = new List<Currency>(CurrencyConversions.ToList());
foreach (var item in newList)
{
Double result;
if (Double.TryParse(Amount, NumberStyles.Any, new System.Globalization.CultureInfo("tr-TR"), out result))
item.CalculatedValue =Math.Round( result * (Direction == "0" ? item.ConversionRateSell : item.ConversionRateBuy),2);
else
item.CalculatedValue = 0;
}
CurrencyConversions = new SmartCollection<Currency>(newList);