Ich habe radiobutton group
, die zwei radiobuttons
wie folgt hat. Ich konnte beide sehen. Ich habe den gleichen Ansatz aus dem folgenden Beispielcode verwendet https://github.com/MvvmCross/MvvmCross-Tutorials/blob/master/ApiExamples/ApiExamples.Core/ViewModels/ViewModels.csCapture ausgewählten RadioButton von der RadioGroup
Wenn ich den Code, um zu debuggen, das Optionsfeld ausgewählt, um zu sehen, habe ich eine Debug-Punkt in der SelectedItem
aber wenn ich Radio-Button ändern es nicht trifft weder Setzen oder erhalten Sie die SelectedItem
. Wie erfassen ich die radiobutton
ViewModel.axml
<MvxRadioGroup
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:textSize="40dp"
local:MvxItemTemplate="@layout/item_radio"
local:MvxBind="ItemsSource Items;SelectedItem SelectedItem" />
Item_Radio.axml
<?xml version="1.0" encoding="utf-8"?>
<RadioButton xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:buttonTint="@color/primary"
local:MvxBind="Text Caption" />
ViewModel.cs ausgewählt ist
private List<Thing> _items = new List<Thing>()
{
new Thing("Open"),
new Thing("Close"),
};
public List<Thing> Items
{
get { return _items; }
set { _items = value; RaisePropertyChanged(() => Items); }
}
private Thing _selectedItem = new Thing("Open");
public Thing SelectedItem
{
get { return _selectedItem; }
set { _selectedItem = value; RaisePropertyChanged(() => SelectedItem); }
}
Thing.cs
public class Thing
{
public Thing(string caption)
{
Caption = caption;
}
public string Caption { get; private set; }
public override string ToString()
{
return Caption;
}
public override bool Equals(object obj)
{
var rhs = obj as Thing;
if (rhs == null)
return false;
return rhs.Caption == Caption;
}
public override int GetHashCode()
{
if (Caption == null)
return 0;
return Caption.GetHashCode();
}
}
Sind Sie ein Binding Warnung im Ausgabefenster zu bekommen? – Plac3Hold3r