Ich habe die folgenden xml
und ViewModel
Quellcode. Ich arbeite an der radiogroup
, wo ich zwei Radiobuttons (Male und Female) habe. Zunächst möchte ich Radio-Button ausgewählt werden (Standard). In meiner aktuellen Implementierung wird jedoch kein Optionsfeld angezeigt. Beide sind als nicht selected.I gezeigt bin mit MvvmCross Version 4.0RadioGroup-Implementierung in MVVMCross
xml
<mvvmcross.droid.support.v7.appcompat.widget.MvxAppCompatRadioGroup
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
local:MvxItemTemplate="@layout/item_radio"
local:MvxBind="ItemsSource Items;ItemSelected SelectedItem" />
Item_radio.xml
<?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:textSize="12sp"
local:MvxBind="Text Caption" />
ViewModel.cs
private List<Thing> _items = new List<Thing>()
{
new Thing("Male"),
new Thing("Female"),
};
public List<Thing> Items
{
get { return _items; }
set { _items = value; RaisePropertyChanged(() => Items); }
}
private Thing _selectedItem = new Thing("Male");
public Thing SelectedItem
{
get
{
return _selectedItem;
}
set
{
_selectedItem = value;
RaisePropertyChanged(() => SelectedItem);
}
}
In den Setup.cs
registry.RegisterFactory(new MvxCustomBindingFactory<MvxAppCompatRadioGroup>("ItemSelected", view => new MyRadioItemSelectedBinding(view)));
, was Ihr macht "item_radio" Layout-Vorlage aussehen? – Plac3Hold3r
Ich habe hinzugefügt, überprüfen Sie bitte Update – hotspring