本文整理汇总了C#中UIView.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# UIView.GetType方法的具体用法?C# UIView.GetType怎么用?C# UIView.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UIView
的用法示例。
在下文中一共展示了UIView.GetType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Parse
public void Parse(UIView view, string caption, Theme theme)
{
var vw = view as IView;
if (vw != null)
{
var captionAttribute = view.GetType().GetCustomAttribute<CaptionAttribute>();
if (captionAttribute != null)
caption = captionAttribute.Caption;
}
Root = new RootElement(caption) { Opaque = false };
Root.DataContext = view;
var dataContext = view as IDataContext;
if (dataContext != null)
Root.DataContext = dataContext.DataContext;
var themeable = Root as IThemeable;
if (themeable != null)
themeable.Theme = Theme.CreateTheme(theme);
var searchbarAttribute = view.GetType().GetCustomAttribute<SearchbarAttribute>();
var searchbar = Root as ISearchBar;
if (searchbarAttribute != null && searchbar != null)
{
searchbar.SearchPlaceholder = searchbarAttribute.Placeholder;
searchbar.IncrementalSearch = searchbarAttribute.IncrementalSearch;
searchbar.EnableSearch = true;
searchbar.IsSearchbarHidden = false;
}
var sectionList = CreateSectionList(view, Root);
sectionList.ForEach((section)=>section.BeginInit());
Root.Add(sectionList);
Root.ToolbarButtons = CheckForToolbarItems(view);
Root.NavbarButtons = CheckForNavbarItems(view);
var notifyDataContextChanged = view as INotifyDataContextChanged;
if (notifyDataContextChanged != null)
{
notifyDataContextChanged.DataContextChanged += HandleNotifyDataContextChangedDataContextChanged;
}
}
示例2: UpdateView
public static void UpdateView(UIView view, object value)
{
if (view != null)
{
string viewTypeName = view.GetType().FullName;
switch (viewTypeName)
{
// TODO: Add cases here for specialized view types, as needed
case "MonoTouch.UIKit.UILabel":
((UILabel)view).Text = value.ToString();
break;
case "MonoTouch.UIKit.UITextField":
{
var textField = (UITextField)view;
string text = value.ToString();
if (textField.Text != text) textField.Text = text;
}
break;
case "MonoTouch.UIKit.UITextView":
{
var textView = (UITextView)view;
string text = value.ToString();
if (textView.Text != text) textView.Text = text;
}
break;
default:
if (view is UITableView)
{
var tableView = (UITableView)view;
var source = tableView.Source as DataBindableUITableViewSource;
if (source != null)
{
var indexPath = source.GetIndexPath(value);
tableView.SelectRow(indexPath, true, UITableViewScrollPosition.Middle);
}
}
else
{
throw new NotImplementedException("View type not implemented: " + viewTypeName);
}
break;
}
}
}
示例3: Binding
/// <summary>
/// Creates a new instance of the Binding class.
/// </summary>
/// <param name="target">A reference to the control to bind to.</param>
/// <param name="targetProperty">The name of the property on the view to bind to.</param>
/// <param name="source">A reference to the object that will be bound to the control.</param>
/// <param name="sourceProperty">The name of the property on the object that will be bound to the target property.</param>
/// <param name="convert">A reference to a function to do a custom conversion from the source property to the target property.</param>
/// <param name="convertBack">A reference to a function to do a custom conversion from the target property to the source property.</param>
/// <param name="bindingDirection">Indicates if the binding is one way or two way.</param>
public Binding(UIView target, string targetProperty, object source, string sourceProperty, Func<object, object> convert, Func<object, object> convertBack, BindingDirection bindingDirection)
{
BindingDirection = bindingDirection;
Target = target;
Source = source;
TargetProperty = Target.GetType().GetProperty(targetProperty);
SourceProperty = Source.GetType().GetProperty(sourceProperty);
Convert = convert;
ConvertBack = convertBack;
var editableControl = Target as UIControl;
if (editableControl != null)
editableControl.EditingDidEnd += Target_EditingDidEnd;
var inpc = Source as INotifyPropertyChanged;
if (inpc != null)
inpc.PropertyChanged += Source_PropertyChanged;
UpdateTarget();
}