Create a list of records

Hello everyone my name is Taniguchi and i beggining developping on xamaring and i using dynamics 365 and there exists an entity named msdyn_timeentry and i would like show their records on a list in xamarin how can do that?
Tagged:

Answers

  • PriyaRastogiPriyaRastogi INMember ✭✭✭


    <ListView.ItemTemplate>




  • PriyaRastogiPriyaRastogi INMember ✭✭✭
            <ListView x:Name="NotificationList"  HasUnevenRows="true" SeparatorVisibility="Default" SeparatorColor="Transparent" ItemsSource="{Binding NotificationList}" ItemSelected="Handle_ItemSelected" BackgroundColor="Transparent">
            <ListView.ItemTemplate>
                <DataTemplate>
                    <ViewCell>
                        <!-- Main design for our menu items -->
                        <StackLayout Orientation="Vertical" VerticalOptions="Center" Padding="10" Spacing="0">
                            <Label Text="{Binding title}" Style="{StaticResource BoldFontWhiteMediumText}" />
                            <Label Text="{Binding description}" Style="{StaticResource RegulerFontWhiteSmallText}" />
                            <Label Text="{Binding createdAt}" Style="{StaticResource RegulerFontWhiteSmallText}" />
                            <BoxView HorizontalOptions="FillAndExpand" HeightRequest="2" BackgroundColor="{StaticResource SkyBlueLineColor}" />
                        </StackLayout>
                    </ViewCell>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>
    
  • PriyaRastogiPriyaRastogi INMember ✭✭✭
        void Handle_ItemSelected(object sender, Xamarin.Forms.SelectedItemChangedEventArgs e)
        {
            if (sender != null)
            {
                var item = (ListView)sender;
                if (item.SelectedItem != null)
                {
                    NotificationList.SelectedItem = null;
                }
            }
        }
    
  • PriyaRastogiPriyaRastogi INMember ✭✭✭
    public class NotificationsPageViewModel : BasePageViewModel
    {
        public RangeEnabledObservableCollection<NotificationListResponse> NotificationList { get; set; }
    

    public NotificationsPageViewModel()
    {
    var list = ApiServices.getNotification();
    NotificationList = new RangeEnabledObservableCollection();
    NotificationList.InsertRange(list);
    }
    }

  • PriyaRastogiPriyaRastogi INMember ✭✭✭

    public class NotificationsPageViewModel : BasePageViewModel
    {
    public RangeEnabledObservableCollection NotificationList { get; set; }
    public NotificationsPageViewModel()
    {
    var list = ApiServices.getNotification();
    NotificationList = new RangeEnabledObservableCollection();
    NotificationList.InsertRange(list);
    }
    }

  • PriyaRastogiPriyaRastogi INMember ✭✭✭
    edited July 5
        public static ObservableCollection<Notification> getNotification()
        {
            var getNotificationList = new ObservableCollection<Notification>();
            getNotificationList.Add(new Notification { HotelName=  "Hard Rock",     NoticationText=  "Lorem ipsum is simply dummy text",    TimeText=" 2 min ago"});
            getNotificationList.Add(new Notification { HotelName = "Hard Rock",     NoticationText = "Lorem ipsum is simply dummy text",    TimeText = " 2 hour ago" });
            getNotificationList.Add(new Notification { HotelName = "Hard Rock",     NoticationText = "Lorem ipsum is simply dummy text",    TimeText = "Yesterday" });
            getNotificationList.Add(new Notification { HotelName = "Hard Rock",     NoticationText = "Lorem ipsum is simply dummy text",    TimeText = " 11 May 2019" });
            getNotificationList.Add(new Notification { HotelName = "Hard Rock",     NoticationText = "Lorem ipsum is simply dummy text" ,   TimeText = " 11 May 2019" });
            getNotificationList.Add(new Notification { HotelName = "Hard Rock",     NoticationText = "Lorem ipsum is simply dummy text",    TimeText = " 11 May 2019" });
            return getNotificationList;
        }
    

    Now This the model class:

    public class Notification
    {
    public string HotelName { get; set; }
    public string NoticationText { get; set; }
    public string TimeText { get; set; }
    }

    You can use this code to insert the record in a list.

Sign In or Register to comment.