ListaEstadoCuenta
是一個列表。這意味着您必須在標籤的綁定中指定項目。例如。第一個項目:
<ViewCell>
<!-- ... -->
<Label Text="{Binding ListaEstadoCuenta[0].Comprobante}" />
<Label Text="{Binding ListaEstadoCuenta[0].FechaDoc}" />
<!-- ... -->
</ViewCell>
如果你想顯示在一個標籤列表中的項目,你必須使用轉換器來組合值:
正值轉換器
public class StringConcatenationConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (value is IEnumerable<EstadoCuentaDetalle>)
{
return string.Join(", ", ((IEnumerable<EstadoCuentaDetalle>)value).Select(x => x.Combrobante));
}
return value;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
資源在你的頁面上
你必須調整本地命名空間xmlns:local
來引用你的程序集名稱。
<ContentPage ...
xmlns:local="clr-namespace:FormsTest;assembly=FormsTest">
<ContentPage.Resources>
<ResourceDictionary>
<local:StringConcatenationConverter x:Key="concatConverter"></local:StringConcatenationConverter>
</ResourceDictionary>
</ContentPage.Resources>
綁定
<Label Text="{Binding ListaEstadoCuenta, Converter={x:StaticResource Key=concatConverter}}" />
你怎麼想表現出來?你也可以發佈你的viewmodel? –
您有一個標籤,但是您的子列表中有多個數據。你想要顯示哪些數據? – Jason
我想顯示muy子目錄 – raranibar