I have a ListView with an Image and some TextBlocks in datatamplate. These controls bind information from an object of a collection but the url for image control is on a file. I tried to bind a string( that is a name to the file) and created a convert to retrieve the url.
xaml:
<ListView Name="list" ItemsSource="{x:Bind Player.PlayerHistory, Mode=OneWay}">
<ListView.ItemTemplate>
<DataTemplate x:DataType="data:HistoricoPartidas">
<Grid HorizontalAlignment="Stretch"
VerticalAlignment="Stretch">
<Image Source="{x:Bind name, Converter={StaticResource ResourceKey=ItemConvert} }" />...
converter:
class ItemConvert: IValueConverter {
public object Convert(object value, Type targetType, object parameter, string language) {
string s = value.ToString(); //value is binding from an object of a collection
ControlFile controle = new ControlFile();//class with file handler
Character ch = controle.get(s).Result;//return a Character from file "s"
return ch.Icon_URL;
}
I created the code above but it causes a deadlock (.Result?). My question is if there is a way to retrieve the data from the file an use in image control avoiding deadlock?