Example #1
0
        /// <summary>
        /// To update application layout
        /// </summary>
        /// <returns>A Task to update application layout asynchrously</returns>
        Task UpdateContentLayout()
        {
            return(Task.Run(() =>
            {
                var selected = ((MainViewModel)BindingContext).SelectedAppControlType;
                var apps = ApplicationControlHelper.GetApplicationIdsForSpecificAppControlType(selected);
                foreach (var app in apps)
                {
                    var iconPath = ApplicationControlHelper.GetApplicationIconPath(app);
                    Device.BeginInvokeOnMainThread(() =>
                    {
                        /// Add an item to the list
                        ((MainViewModel)BindingContext)
                        .Applications.Add(new ApplicationListItem
                        {
                            Id = app,
                            IconPath = iconPath,
                            BlendColor = Color.Gray,
                        });
                    });
                }

                Device.BeginInvokeOnMainThread(() =>
                {
                    /// Add an extra empty item.
                    ((MainViewModel)BindingContext)
                    .Applications.Add(new ApplicationListItem
                    {
                        Id = null,
                        IconPath = null,
                        BlendColor = Color.Gray,
                    });
                });
            }));
        }
Example #2
0
        /// <summary>
        /// To update application layout
        /// </summary>
        /// <returns>A Task to update application layout asynchrously</returns>
        Task UpdateContentLayout()
        {
            return(Task.Run(() =>
            {
                Device.BeginInvokeOnMainThread(() =>
                {
                    _applications.Children.Clear();
                });

                var selected = ((MainViewModel)BindingContext).SelectedAppControlType;
                var apps = ApplicationControlHelper.GetApplicationIdsForSpecificAppControlType(selected);
                foreach (var app in apps)
                {
                    var iconPath = ApplicationControlHelper.GetApplicationIconPath(app);
                    Device.BeginInvokeOnMainThread(() =>
                    {
                        /// Add an item to the list
                        var item = new ApplicationListItem
                        {
                            Id = app,
                            IconPath = iconPath,
                            BlendColor = Color.Gray,
                        };
                        ((MainViewModel)BindingContext).Applications.Add(item);

                        _applications.AddItem(item).Selected += OnItemSelected;
                    });
                }

                Device.BeginInvokeOnMainThread(() =>
                {
                    /// Add an empty item to the list
                    var item = new ApplicationListItem
                    {
                        Id = null,
                        IconPath = null,
                        BlendColor = Color.Gray,
                    };
                    ((MainViewModel)BindingContext).Applications.Add(item);

                    _applications.AddItem(item);
                });

                /// For application list
                Children.Add(
                    _applications,
                    Constraint.RelativeToParent((parent) =>
                {
                    return 0;
                }),
                    Constraint.RelativeToParent((parent) =>
                {
                    return parent.Height * 0.2411;
                }),
                    Constraint.RelativeToParent((parent) =>
                {
                    return parent.Width;
                }),
                    Constraint.RelativeToParent((parent) =>
                {
                    return parent.Height * 0.5265;
                }));
            }));
        }