我正在尝试将字节 [] 格式化为字符串以在 IO 应用程序中显示,这里的问题是转换器从未启动我实际上有:
转换器类
class ByteArrayToTextValueConverter : MvxValueConverter<byte[], string>
{
protected override string Convert(byte[] value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (value is byte[])
{
return "test";
/*
var byteArray = (byte[])value;
return Encoding.UTF8.GetString(byteArray, 0, byteArray.Length);
*/
}
return "";
}
protected override byte[] ConvertBack(string value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (value is string)
{
var text = (string)value;
return Encoding.UTF8.GetBytes(text);
}
return new byte[] { };
}
}
查看剪贴簿留言:
var source = new MvxSimpleTableViewSource(
TableView,
SubtitleDetailViewCell.Key,
SubtitleDetailViewCell.Key
);
TableView.Source = source;
TableView.RowHeight = 50;
TableView.RegisterClassForCellReuse(typeof(SubtitleDetailViewCell), SubtitleDetailViewCell.Key);
var set = this.CreateBindingSet<ObservationsView, ObservationsViewModel>();
set.Bind(source).To(vm => vm.Observations);
//set.Bind(source).For(s => s.SelectionChangedCommand).To(vm => vm.SelectedObsCommand);
set.Apply();
TableView.ReloadData();
自定义单元格类:
public SubtitleDetailViewCell(IntPtr handle)
: base(handle)
{
Initialize();
this.DelayBind(() =>
{
var set = this.CreateBindingSet<SubtitleDetailViewCell, ObservationMedicale>();
set.Bind(MainLbl).To(observation => observation.Texte).WithConversion("ByteArrayToText");
set.Bind(SubLeftLbl).To(observation => observation.SaisieLe);
set.Bind(SubRightLbl).To(observation => observation.PraticienNom);
set.Apply();
});
}