本文整理汇总了C#中Xamarin.Forms.DataTemplate类的典型用法代码示例。如果您正苦于以下问题:C# DataTemplate类的具体用法?C# DataTemplate怎么用?C# DataTemplate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DataTemplate类属于Xamarin.Forms命名空间,在下文中一共展示了DataTemplate类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GroupMatchView
public GroupMatchView()
{
BindingContext = new GroupMatchesViewModel();
var activity = new ActivityIndicator
{
Color = Helpers.Color.Greenish.ToFormsColor(),
IsEnabled = true
};
activity.SetBinding(ActivityIndicator.IsVisibleProperty, "IsBusy");
activity.SetBinding(ActivityIndicator.IsRunningProperty, "IsBusy");
this.Groups = new ObservableCollection<GroupHelper>();
var refresh = new ToolbarItem
{
Command = ViewModel.LoadItemsCommand,
Icon = "refresh.png",
Name = "refresh",
Priority = 0
};
ToolbarItems.Add(refresh);
ViewModel.ItemsLoaded += new EventHandler((sender, e) =>
{
this.Groups.Clear();
ViewModel.Result.Select(r => r.MatchDate).Distinct().ToList()
.ForEach(r => Groups.Add(new GroupHelper(r)));
foreach (var g in Groups)
{
foreach (var match in ViewModel.Result.Where(m=> m.MatchDate == g.Date))
{
g.Add(match);
}
}
});
Title = "Group Match Schedule";
var stack = new StackLayout
{
Orientation = StackOrientation.Vertical,
Padding = new Thickness(0, 0, 0, 8)
};
var listView = new ListView
{
IsGroupingEnabled = true,
GroupDisplayBinding = new Binding("Date"),
};
var viewTemplate = new DataTemplate(typeof(ScoreCell));
listView.ItemTemplate = viewTemplate;
listView.ItemsSource = Groups;
stack.Children.Add(activity);
stack.Children.Add(listView);
Content = stack;
}
示例2: LeadListView
public LeadListView()
{
HasUnevenRows = false; // Circumvents calculating heights for each cell individually. The rows of this list view will have a static height.
RowHeight = RowSizes.LargeRowHeightInt; // set the row height for the list view items
SeparatorVisibility = SeparatorVisibility.None; // make the row separators invisible, per the intended design of this app
ItemTemplate = new DataTemplate(typeof(LeadListItemCell));
}
示例3: RssFeedView2
public RssFeedView2()
{
this.viewModel = new RssFeedViewModel();
this.BindingContext = viewModel;
this.Title = "Rss Feed";
var refresh = new ToolbarItem(){ Command = viewModel.ReloadCommand, Name = "Reload", Priority = 0 };
ToolbarItems.Add(refresh);
var stack = new StackLayout(){ Orientation = StackOrientation.Vertical };
var activity = new ActivityIndicator(){ Color = Color.Blue, IsEnabled = true };
activity.SetBinding(ActivityIndicator.IsVisibleProperty, "ShowActivityIndicator");
activity.SetBinding(ActivityIndicator.IsRunningProperty, "ShowActivityIndicator");
stack.Children.Add(activity);
var listview = new ListView();
listview.ItemsSource = viewModel.Records;
var cell = new DataTemplate(typeof(ImageCell));
cell.SetBinding(ImageCell.TextProperty, "Title");
cell.SetBinding(ImageCell.ImageSourceProperty, "Image");
listview.ItemTemplate = cell;
listview.ItemSelected += async (sender, e) => {
await Navigation.PushAsync(new RssWebView((RssRecordViewModel)e.SelectedItem));
listview.SelectedItem = null;
};
stack.Children.Add(listview);
Content = stack;
}
示例4: ListViewEx
public ListViewEx()
{
var classNames = new[]
{
"Building Cross Platform Apps with Xamarin Part1",
"Building Cross Platform Apps with Xamarin Part2",
"Building Cross Platform Apps with Xamarin Part3"
};
//TODO: Translate into XAML
Padding = new Thickness(0, Device.OnPlatform(20, 0, 0), 0, 0);
var listView = new ListView();
//listView.ItemsSource = classNames;
listView.ItemsSource = PluralsightCourse.GetCourseList();
var cell = new DataTemplate(typeof(TextCell));
//cell.SetBinding(TextCell.TextProperty, new Binding("."));
cell.SetBinding(TextCell.TextProperty, new Binding("Title"));
cell.SetBinding(TextCell.DetailProperty, new Binding("Author"));
cell.SetValue(TextCell.TextColorProperty, Color.Red);
cell.SetValue(TextCell.DetailColorProperty,Color.Yellow);
listView.ItemTemplate = cell;
Content = listView;
}
示例5: CustomerListView
public CustomerListView()
{
HasUnevenRows = false; // Circumvents calculating heights for each cell individually. The rows of this list view will have a static height.
RowHeight = (int)Sizes.LargeRowHeight; // set the row height for the list view items
ItemTemplate = new DataTemplate(typeof(CustomerListItemCell));
SeparatorColor = Palette._013;
}
示例6: Init
public void Init()
{
if (Device.OS == TargetPlatform.iOS) {
var list = new EditableListView<Object> ();
list.SetBinding (EditableListView<Object>.SourceProperty, "JellyBeanValues");
list.ViewType = typeof(JellyBeanListViewCell);
list.CellHeight = 60;
list.AddRowCommand = new Command (() => {
this.DisplayAlert ("Sorry", "Not implemented yet!", "OK");
});
if (PageModel.JellyBeanValues != null)
list.Source = PageModel.JellyBeanValues;
Content = list;
} else {
var list = new ListView();
list.SetBinding (ListView.ItemsSourceProperty, "JellyBeanValues");
var celltemp = new DataTemplate(typeof(TextCell));
celltemp.SetBinding (TextCell.TextProperty, "Name");
celltemp.SetBinding (TextCell.DetailProperty, "ReadableValues");
list.ItemTemplate = celltemp;
if (PageModel.JellyBeanValues != null)
list.ItemsSource = PageModel.JellyBeanValues;
Content = list;
}
ToolbarItems.Add(new ToolbarItem("Add", "", () => {
this.DisplayAlert("Sorry", "Not implemented yet!", "OK");
}));
}
示例7: Init
protected override void Init ()
{
var presidents = new List<President> ();
for (int i = 0; i < 10; i++) {
presidents.Add (new President ($"Presidente {44 - i}", 1, $"http://static.c-span.org/assets/images/series/americanPresidents/{43 - i}_400.png"));
}
var header = new Label {
Text = "Presidents",
HorizontalOptions = LayoutOptions.Center
};
var cell = new DataTemplate (typeof(CustomCell));
var listView = new ListView {
ItemsSource = presidents,
ItemTemplate = cell,
RowHeight = 200
};
Content = new StackLayout {
Children = {
header,
listView
}
};
}
示例8: FootballPlayerListPage
public FootballPlayerListPage()
{
this.BindingContext = new FootballPlayerViewModel ();
Title = "Football Legends";
var create = new ToolbarItem ();
create.Name = "create";
this.ToolbarItems.Add (create);
create.Clicked += Create_Clicked;
// create.SetBinding (ToolbarItem.CommandProperty, "CreatePlayer");
MyFootballList = new ListView ();
MyFootballList.IsPullToRefreshEnabled = true;
MyFootballList.Refreshing += MyFootballList_Refreshing;
MyFootballList.SetBinding (ListView.ItemsSourceProperty, "Footballplayercollection");
var cell = new DataTemplate (typeof(FootballPlayerListCell));
MyFootballList.ItemTemplate = cell;
MyFootballList.RowHeight = 70;
MessagingCenter.Subscribe<FootballPlayerListCell>(this,"delete",(sender) => {
this.BindingContext = new FootballPlayerViewModel();
FootballPlayer dat= new FootballPlayer ();
MyFootballList.ItemsSource = dat.GetItems ();
},null);
MyFootballList.ItemSelected += (object sender, SelectedItemChangedEventArgs e) =>
{
Navigation.PushAsync(new FootballPlayerDetailPage(e.SelectedItem));
};
this.Content = MyFootballList;
}
示例9: RefreshAsync
private async Task RefreshAsync()
{
listView.ItemsSource = await App.CustManager.GetTasksAsync ();
var cell = new DataTemplate (typeof(TextCell));
listView.ItemTemplate = new DataTemplate (typeof(CustomerCell));
}
示例10: EventListView
public EventListView(EventViewModel viewModel)
{
BindingContext = viewModel;
var stack = new StackLayout
{
Orientation = StackOrientation.Vertical,
Padding = new Thickness(0, 10)
};
var progress = new ActivityIndicator
{
IsEnabled = true,
Color = Color.White
};
progress.SetBinding(IsVisibleProperty, "IsBusy");
progress.SetBinding(ActivityIndicator.IsRunningProperty, "IsBusy");
stack.Children.Add(progress);
var listView = new ListView {ItemsSource = viewModel.Events};
var itemTemplate = new DataTemplate(typeof (TextCell));
itemTemplate.SetBinding(TextCell.TextProperty, "Name");
listView.ItemTemplate = itemTemplate;
stack.Children.Add(listView);
Content = stack;
}
示例11: SessionsMenuPage
public SessionsMenuPage()
{
//TODO : Step 03-3 - Add menu button
//Title = "Menu";
//TODO : Step 03-8 - Add menu button
//Icon = "sessions.png";
#region Initialize Page
this.Padding = new Thickness (0, Device.OnPlatform (40, 0, 0), 0, 0);
var sessions = Repository.GetSessions ();
var cell = new DataTemplate (typeof(TextCell));
cell.SetBinding (TextCell.TextProperty, "Title");
var listView = new ListView {
ItemsSource = sessions,
ItemTemplate = cell
};
#endregion
//TODO : Step 03-4 - Send event when item selected
// listView.ItemSelected += (sender, args) => {
// if (args.SelectedItem != null) {
// MessagingCenter.Send (new SessionSelected (args.SelectedItem as Session), "SessionSelected");
// listView.SelectedItem = null;
// }
// };
Content = listView;
}
示例12: createTagListStack
/** Create Tag List stack
**/
public StackLayout createTagListStack(Button done)
{
// Initialise tags
Tags[] tagAr = initTags ();
// Create the shown elements
ListView lView = new ListView {
BackgroundColor = Color.FromHex("#007064"),
};
// Setup those elements
lView.ItemSelected += noSelection;
lView.ItemTapped += tappedSelection;
DataTemplate template = new DataTemplate (typeof (customCellTags));
lView.ItemsSource = tagAr;
lView.ItemTemplate = template;
// Create the layout to show those elements
StackLayout options = new StackLayout {
Spacing = 15,
Padding = new Thickness(15,15,15,15),
VerticalOptions = LayoutOptions.StartAndExpand,
Orientation = StackOrientation.Vertical,
HorizontalOptions = LayoutOptions.EndAndExpand,
Children = {lView, done}
};
return options;
}
示例13: PFDictionaryView
public PFDictionaryView()
{
viewModel = new PFDictionaresViewModel();
ItemsSource = viewModel.PFDictionariesGrouped;
IsGroupingEnabled = true;
GroupDisplayBinding = new Binding("Key");
GroupShortNameBinding = new Binding("Key");
if(Device.OS != TargetPlatform.WinPhone)
GroupHeaderTemplate = new DataTemplate(typeof(HeaderCell));
var cell = new DataTemplate(typeof(PFDictCell));
ItemTemplate = cell;
//SeparatorVisibility = SeparatorVisibility.None;
RowHeight = 60;
ItemTapped += (sender, args) =>
{
var pfdic = args.Item as PFDictionary;
if (pfdic == null)
return;
//Navigation.PushAsync(new DetailsPage(pfdic));
// Reset the selected item
SelectedItem = null;
};
}
示例14: ProductPage
public ProductPage (String uid)
{
Title = "Produits";
var dataTemplate = new DataTemplate (typeof(TextCell));
dataTemplate.SetBinding (TextCell.TextProperty, "name");
dataTemplate.SetBinding (TextCell.DetailProperty, "price");
list = new ListView ();
list.ItemTemplate = dataTemplate;
list.IsPullToRefreshEnabled = true;
list.RefreshCommand = new Command (() => loadProductData());
list.ItemSelected += (object sender, SelectedItemChangedEventArgs e) => {
if(e.SelectedItem == null)
return;
Product product = (Product)e.SelectedItem;
list.SelectedItem = null;
//TODO: implement nav to product detail page
//this.Navigation.PushAsync (new ProductPage(category.uid));
};
Content = list;
this.categoryUid = uid;
list.BeginRefresh ();
}
示例15: SchoolPickerPage
public SchoolPickerPage(LoginPage page)
{
InitializeComponent ();
_Context = SynchronizationContext.Current;
Search.TextChanged += (object sender, TextChangedEventArgs e) =>
{
if ((DateTime.Now - _PreviousGet).TotalSeconds < 4 && Search.Text.Length > 3)
{
GetSchoolData();
_PreviousGet = DateTime.Now;
}
};
Search.SearchButtonPressed += (object sender, EventArgs e) => {
GetSchoolData();
_PreviousGet = DateTime.Now;
};
var SchoolTemplate = new DataTemplate (typeof(Xamarin.Forms.TextCell));
SchoolTemplate.SetBinding (TextCell.TextProperty, new Binding ("Name"));
SchoolTemplate.SetBinding (TextCell.DetailProperty, new Binding ("Url"));
Results.ItemTemplate = SchoolTemplate;
Results.ItemTapped += (object sender, ItemTappedEventArgs e) => {
page.SelectSchool((Magister.School)e.Item);
Navigation.PopModalAsync();
};
}