我正在使用MVC.net,在单击后很难通过引导侧边栏li保持活动状态,并且在我单击时一直刷新页面。
但是我仍然尝试使用下面提供的示例,单击后仍然无法激活。
我从链接中尝试了几个答案单击 option1 here 然后点击 option2 here
下面是我的代码:
CurrentControllerActiveClassName:
[assembly: ExportRenderer(typeof(MyPicker), typeof(MyPickerRenderer))]
namespace xxx.iOS
{
public class MyPickerRenderer:PickerRenderer,IUIPickerViewDelegate,IUIPickerViewDataSource
{
string SelectedValue;
public MyPickerRenderer()
{
}
public nint GetComponentCount(UIPickerView pickerView)
{
return 1;
}
public nint GetRowsInComponent(UIPickerView pickerView, nint component)
{
return Element.Items.Count;
}
[Export("pickerView:viewForRow:forComponent:reusingView:")]
public UIView GetView(UIPickerView pickerView, nint row, nint component, UIView view)
{
UILabel label = new UILabel
{
TextColor = UIColor.Blue,
Text = Element.Items[(int)row].ToString(),
TextAlignment = UITextAlignment.Center,
};
var picker = this.Element;
return label;
}
[Export("pickerView:didSelectRow:inComponent:")]
public void Selected(UIPickerView pickerView, nint row, nint component)
{
Control.Text = Element.Items[(int)row];
SelectedValue= Element.Items[(int)row];
}
protected override void OnElementChanged(ElementChangedEventArgs<Picker> e)
{
base.OnElementChanged(e);
if(Control!=null)
{
SelectedValue = Element.Items[0];
UIPickerView pickerView = (UIPickerView)Control.InputView;
pickerView.WeakDelegate = this;
pickerView.DataSource = this;
// get the button Done and rewrite the event
UIToolbar toolbar = (UIToolbar)Control.InputAccessoryView;
UIBarButtonItem done = new UIBarButtonItem("Done", UIBarButtonItemStyle.Done, (object sender, EventArgs click) =>
{
Control.Text = SelectedValue;
toolbar.RemoveFromSuperview();
pickerView.RemoveFromSuperview();
Control.ResignFirstResponder();
});
UIBarButtonItem empty = new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace, null);
toolbar.Items = new UIBarButtonItem[] { empty,done };
}
}
}
}
HTML布局:
#! /usr/bin/env python
import sys, os, glob
mylist = ['fish.txt','random.txt', 'expo.txt']
def sorter(item):
for item in mylist:
return item
for file in sorted(glob.glob('*.txt'), key = sorter):
print(file)
jQuery:
public string CurrentControllerActiveClassName(string targetController)
{
var controller = ViewContext.RouteData.Values["controller"];
return controller.Equals(targetController) ? "active" : string.Empty;
}
点击侧边栏时,结果应保持活动状态。