xamarin - 向 VM 发送字节不起作用 Xamarin
问题描述
我有行为
public class FolderDialogBehavior : Behavior<View>
{
public byte[] ImageBytes{ get { return (byte[])GetValue(ImageBytesProperty); } set { SetValue(ImageBytesProperty, value); } }
public readonly static BindableProperty ImageBytesProperty = BindableProperty.Create(nameof(ImageBytes), typeof(byte[]),
typeof(FolderDialogBehavior), defaultValue: null, BindingMode.TwoWay);
// Some Code
private async void GetPhotoAsync()
{
// Some Code
ImageBytes = bytes;
}
}
我也有 ViewModel
public class StudentViewModel : OnPropertyChangedClass
{
private byte[] _userImage;
public byte[] UserImage
{
get => _userImage;
set => SetProperty(ref _userImage, value);
}
}
问题是 ImageBytes 不会向我的 ViewModel 发送新信息。如果我将byte[]更改为字符串,一切正常
<Grid Content BindingContext="{Binding AddEmployee, Mode=OneWay}">
<Grid.Behaviors>
<local:FolderDialogBehavior ImageBytes="{Binding StudentObject.UserImage, Mode=TwoWay}"/>
</Grid.Behaviors>
</Grid>
解决方案
推荐阅读
- java - 这段代码中的二叉搜索树会是什么样子?
- sql-server - SQL连接具有相同外键的三个表不组合表2和3数据
- c++ - CLion 无法从源中检测类,并且没有智能感知/代码完成
- python - Django 过滤器“小于”日期时间无法正常工作
- javascript - 更好的算法在 JS 中生成随机数
- python - 如何在 Flask 中显示 Stripe 卡错误的错误消息
- android - TextToSpeech Android 无法正常工作
- c - GC_MALLOC 是否真的对应 calloc()?
- java - 我如何使用 Citizens API 生成 NPC?
- python - 检测python程序是否通过Windows GUI(双击)vs命令提示符执行