Android/iOS 앱에 MvvmCross 3.2.2를 사용하고 있으며, 해당 항목이 화면에서 뒤로 스크롤되어 있지 않은 한 새로 고치지 않고 ImageView에서 DrawableName을 사용하여 바인딩 된 MvxListView가 발생합니다.MvvmCross Android MvxListView DrawableName 새로 고치지 않습니다.
DataModel이
public class VehicleStatus
{
public string VehicleRegistration { get; set; }
public bool Selected { get; set; }
public string DrawableName
{
get
{
string res = (Selected) ? "on" : "off";
return res;
}
}
}
모두 "ON"과 "OFF"드로어 블 Drawable 폴더 내에있는 PNG 자원입니다.
MvxListView 레이아웃 발췌
<Mvx.MvxListView
android:id="@+id/listItems"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:dividerHeight="2dp"
android:divider="@drawable/list_divider"
local:MvxBind="ItemsSource Units; ItemClick VehicleSelectedCommand"
local:MvxItemTemplate="@layout/list_unit" />
MvxItemTemplate
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res/xxxxxxx.Droid"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:background="@color/white"
android:layout_height="62dp">
<TextView
android:id="@+id/unitsName"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:textSize="18dp"
android:gravity="center"
android:layout_margin="7dp"
android:textColor="@color/verydarknavy"
local:MvxBind="Text VehicleRegistration" />
<ImageView
android:id="@+id/notificationUnitImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="21dp"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"
local:MvxBind="DrawableName DrawableName "
android:tint="@color/verydarknavy" />
</RelativeLayout>
뷰 모델
private ObservableCollection<VehicleStatus> _units;
public ObservableCollection<VehicleStatus> Units
{
get { return _units; }
set { _units = value;
RaisePropertyChanged (() => Units); }
}
및 명령
public void VehicleSelected (VehicleStatus item)
{
if (item != null)
{
foreach (var unit in _units)
{
if (unit.Id == item.Id)
{
unit.Selected = !unit.Selected;
break;
}
}
RaisePropertyChanged (() => Units);
}
}
private MvxCommand<VehicleStatus> _vehicleSelectedCommand;
public System.Windows.Input.ICommand VehicleSelectedCommand
{
get
{
_vehicleSelectedCommand = _vehicleSelectedCommand ?? new MvxCommand<VehicleStatus>(VehicleSelected);
return _vehicleSelectedCommand;
}
}
나는 그것이 모든 관련 비트라고 생각한다. ImageView를 새로 고치기 위해 무언가를 놓치고 있다고 가정하지만, 나는 모릅니다. 어떤 아이디어라도 감사 할 것입니다.
덕분에 지금은 꿈처럼 작동하는 스튜어트 !!!! – JDibble