【发布时间】:2022-06-18 02:39:20
【问题描述】:
我正在开发一个很快就会有服务器/数据库的应用程序。我想完成列表图像和 xaml 之间的绑定。知道如何进行吗?
public class Profile : INotifyPropertyChanged
{
/** --------------------------------------------------------------------
* Properties
* --------------------------------------------------------------------
*/
List<Image> images;
public List<Image> Images
{
get { return images; }
set { images = value; OnPropertyChanged(nameof(Images)); }
}
public Profile()
{
Images.Add(new Image());
Images.Add(new Image());
}
...
<ImageButton Source="{Binding Profile.Images[0].Source}" Aspect="AspectFill" HeightRequest="630"></ImageButton>
【问题讨论】:
-
是
ImageXamarin.Forms.Image,还是别的什么? XF Image 是一个 UI 控件,实际上不应该这样使用。 -
绑定到字符串列表(包含文件路径)或
ImageSources 列表。确保定义一个公共属性。public … { get; set; }
标签: c# xaml xamarin.forms binding maui