3 개의 탭이 연결된 간단한 ActionBar가 있습니다. 탭을 클릭하면 조각이 팽창되고보기가 표시됩니다. 탭중인 클릭 이벤트는 이벤트를 사용하여 시작됩니다. 처음에는 첫 번째 조각이 팽창되지만 다른 조각은 클릭하면 반응하고 팽창합니다.탭을 선택하면 ICommand가 항상 실행되지 않음
내가 해고하는 이벤트를 ICommand
으로 변경하면 마지막 조각 만 팽창되고 첫 번째 탭을 클릭하면 마지막 이벤트가 팽창됩니다. 두 번째.
내 코드는 내가 ICommands 및 이벤트의 차이 여기에 근본적인 뭔가 누락하거나 뭔가 다른이
ICommand TabClicked
{
get
{
return new RelayCommand(() =>
{
tab.TabSelected += (object sender, ActionBar.TabEventArgs e) => TabOnTabSelected(sender, e);
});
}
}
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.Main);
ActionBar.NavigationMode = ActionBarNavigationMode.Tabs;
fragments.Add(new TODFragment());
fragments.Add(new ConditionsFragment());
fragments.Add(new ResultsFragment());
AddTabToActionBar("Time", Resource.Drawable.crucifix_colour);
AddTabToActionBar("Conditions", Resource.Drawable.weather_colour);
AddTabToActionBar("Results", Resource.Drawable.tod_colour);
}
void AddTabToActionBar(string text, int iconResourceId)
{
tab = ActionBar.NewTab().SetTag(text).SetText(text).SetIcon(iconResourceId);
/* uncomment and comment out one of the two below to see the difference in operation */
tab.TabSelected += TabOnTabSelected;
//tab.SetCommand<ActionBar.TabEventArgs>("TabSelected", TabClicked);
ActionBar.AddTab(tab);
}
void TabOnTabSelected(object sender, ActionBar.TabEventArgs tabEventArgs)
{
var tabNo = sender as ActionBar.Tab;
var frag = fragments[tabNo.Position];
tabEventArgs.FragmentTransaction.Replace(Resource.Id.frameLayout1, frag);
}
암이다? 내가 Xam.Android 및 MVVMLight