Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all 58056 articles
Browse latest View live

Is there a way to get XAML binding intellisense in a separate ContentView file used in a ListView?

$
0
0

I have a ListView with this item template:

<ListView.ItemTemplate>
  <DataTemplate>
    <ViewCell>
      <views:ProjectListEntry />
    </ViewCell>
  </DataTemplate>
</ListView.ItemTemplate>

ProjectListEntry is fairly complex and is used in another ListView, so I have it in its own file. I've set it up like this:

<ContentView
    xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    ...
    BindingContext="{x:Static helpers:DesignTimeData.ProjectListEntryVm}">

As you can see, to get Intellisense, I tried to set BindingContext to a static member on the DesignTimeData class. This works fine for my Pages (where I replace the BindingContext at runtime), but for ContentViews used in ListViews, the ContentView's BindingContext seems to be inherited (from the ViewCell, I guess). This means that the explicit BindingContext on my ContentView will actually override the BindingContext set on the ViewCell by the ListView, and all my list elements will reflect the static design-time data at runtime. But if I remove the BindingContext, I get no intellisense for the members I bind to inside the ContentView file.

Is there a simple way to get Intellisense for bindings in a ContentView like this? (As mentioned, I can't inline the ContentView in the ListView definition, because the ContentView is fairly complex and used in several lists. I also can't use some kind of VM locator, because although I'm using bindings, I'm not using "full" MVVM - I'm using a Redux-like architecture instead. And I guess a VM locator wouldn't work for this case anyway for the same reasons the above doesn't work.)


is there any update for xamarin.social is coming for .net standard 2.0 or suggest any alternative.

$
0
0

xamarin.social is targeting framework 4.6.1

Handling the tap events on image in xamarin.forms?

$
0
0

Can you anyone Please help me on this? How to handle the tap events on xamarin.forms. even i gave numbertaps required=2 in xaml it s executing number of times.
my scenario is image is in xaml page and i gave number taps required is "2" when i click on 2 times with no time its executing many times.

how to set (no of taps to) 1 in tap command in mvvm xamarin forms?

$
0
0

i have given tap gesture to image .... when i tapped image multiple times then page is also opening multiple times....i want to open page for only one tap...i have already given no of taps=1...but not working..how to do???

[Material] how to gain access to `Toolbar` from custom renderer?

$
0
0

Based on @TheRealJasonSmith's gist on how to add Material design to your Forms.Android app, I've implemented the "Toolbar" instead of the "ActionBar".

I'm wondering how I might go about getting access to that View in order to set the NavigationIcon to the Page.Icon?

Right now I've got a custom renderer that is attempting to set the Toolbar NavigationIcon like so, but toolbar is always null

[assembly: ExportRenderer(typeof(Page), typeof(Renderers.ExtendedPageRenderer))]
namespace Renderers
{
    public class ExtendedPageRenderer : PageRenderer
    {
        protected override void OnElementChanged(ElementChangedEventArgs<Page> e)
        {
            base.OnElementChanged(e);

            if (Element != null && Element.Icon != null)
            {
                var iconId = ResourceManager.GetDrawableByName(Element.Icon.File);
                var toolbar = FindViewById<Toolbar>(Resource.Id.toolbar);
                if (toolbar != null)
                {
                    toolbar.SetNavigationIcon(iconId);
                }
            }
        }
    }
}

[android] label renderer apply to all labels

$
0
0

I have forms app, and I have custom label as following,

public class HtmlFormattedLabel : Label
    {
        public float mySize { get; set; }
    }

and I have custom renderer in both android and ios as following:

Android:

[assembly: ExportRenderer(typeof(HtmlFormattedLabel), typeof(HtmlFormattedLabelRenderer))]
namespace HBRS.Droid.Renderers
{
    public class HtmlFormattedLabelRenderer : LabelRenderer
    {

        public HtmlFormattedLabelRenderer(Context context) : base(context)
        {

        }
        protected override void OnElementChanged(ElementChangedEventArgs<Label> e)
        {
            base.OnElementChanged(e);

            HtmlFormattedLabel view = (HtmlFormattedLabel)Element;
            if (view == null) return;

            Control.Gravity = Android.Views.GravityFlags.Right;
            Control.SetTextSize(Android.Util.ComplexUnitType.Sp, view.mySize);

            if (Android.OS.Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.N)
                Control.SetText(Html.FromHtml(view.Text.ToString(), FromHtmlOptions.ModeLegacy), TextView.BufferType.Normal);
            else
                Control.SetText(Html.FromHtml(view.Text.ToString()), TextView.BufferType.Normal);
        }
    }
}

iOS

    [assembly: ExportRenderer(typeof(HtmlFormattedLabel), typeof(HtmlFormattedLabelRenderer))]
    namespace HBRS.iOS.Renderers
    {
        public class HtmlFormattedLabelRenderer : LabelRenderer
        {
            protected override void OnElementChanged(ElementChangedEventArgs<Label> e)
            {
                base.OnElementChanged(e);

                var view = (HtmlFormattedLabel)Element;
                if (view == null) return;
                UIStringAttributes te = new UIStringAttributes();
                var attr = new NSAttributedStringDocumentAttributes();
                var nsError = new NSError();
                attr.DocumentType = NSDocumentType.HTML;
                attr.StringEncoding = NSStringEncoding.UTF8;
                attr.ViewMode = NSDocumentViewMode.PageLayout;
                Control.AttributedText = new NSAttributedString(view.Text, attr, ref nsError);
            }
        }
    }

the problem that in android, the renderer applied to all labels in the app, (when I change size of the custom label all the label sizes changes)

ListView inside CarouselView : Scroll hardly

$
0
0

Hey,

I created a Listview inside a CarouselView, but when i want to scroll in my listview, my carousel can take the focus and it can horizontal scroll too.

How can I lock my carouselView ?

Thanks

SearhBox (Multiselect page)

$
0
0

I have an ObservableCollection with list of users data which is wrapped for multiselect page.
I added SearhBox to the multiselect page but I can not make it work.
Here is an example of code:

public class WrappedItemSelectionTemplate : ViewCell
            {
                public WrappedItemSelectionTemplate() : base()
                {


                    Label Title = new Label() { TextColor = Color.Black };

                    Title.SetBinding(Label.TextProperty, new Binding("Item.Title"));
                    Label Email = new Label() { FontSize = 14 };

                    Email.SetBinding(Label.TextProperty, new Binding("Item.Email"));

                    Switch mainSwitch = new Switch() { HorizontalOptions = LayoutOptions.End };
                    mainSwitch.SetBinding(Switch.IsToggledProperty, new Binding("IsSelected"));


                    StackLayout Stack = new StackLayout();

                    Stack.Children.Add(Title);
                    Stack.Children.Add(Email);
                    Grid grid = new Grid();
                    grid.Children.Add(Stack, 0,0);
                    grid.Children.Add(Email, 0, 1);
                    grid.Children.Add(mainSwitch, 1, 0);
                    View = grid;
                }
            }
            public List<WrappedSelection<T>> WrappedItems = new List<WrappedSelection<T>>();

            public SelectMultipleBasePage(List<T> items)
            {
                WrappedItems = items.Select(item => new WrappedSelection<T>() { Item = item, IsSelected = false }).ToList();
                ListView mainList = new ListView()
                {
                    ItemsSource = WrappedItems,
                    ItemTemplate = new DataTemplate(typeof(WrappedItemSelectionTemplate)),
                };

                mainList.ItemSelected += (sender, e) =>
                {
                    if (e.SelectedItem == null) return;
                    var o = (WrappedSelection<T>)e.SelectedItem;
                    o.IsSelected = !o.IsSelected;
                    ((ListView)sender).SelectedItem = null; //de-select
                };

                // SearchBar added
                StackLayout Stack = new StackLayout();
                SearchBar Search = new SearchBar(); 
                Stack.Children.Add(Search);
                Stack.Children.Add(mainList);
                Search.TextChanged += (sender, e) =>
                {
                    SearchBar_TextChanged();
                };
                Content = Stack;

                void SearchBar_TextChanged()
                {


                }
            }

When I ussed SearchBox in my cases before I was filtering an ObservableCollection like:

new ObservableCollection<Models.M_UsersAndGroups>(
from user in userList           
where (!String.IsNullOrEmpty(user.Title) && user.Title.IndexOf(keyword, StringComparison.OrdinalIgnoreCase) >= 0) 
select user)

But I can't do the same because it's wrapped. How I can use SearhBox for field Title in that case?


How to collapse a row in a grid?

$
0
0

I've a view with a grid with 3 rows. In the first row ( 0 ) there is an image like as header. I wish to collapse the row0 when I tap on image to I've more space in the view.
How doing?

How to drawing a Rectangle using SkiaSharp?

$
0
0

Hi everybody!
How to drawing a Rectangle using SkiaSharp?
If you have better way, please tell me!
Thank you!

Attempt to invoke virtual method 'android.content.res.Resources android.content.Context.getResources

$
0
0

Hey Guys,
I am facing a problem with my android project of my Xamairn.Forms Application.

When I run the Solution I get the following Exception:
07-19 15:02:10.323 E/mono ( 3650): 07-19 15:02:10.323 E/mono ( 3650): Unhandled Exception: 07-19 15:02:10.323 E/mono ( 3650): Java.Lang.NullPointerException: Attempt to invoke virtual method "android.content.res.Resources android.content.Context.getResources()" on a null object reference 07-19 15:02:10.323 E/mono ( 3650): at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/data/lanes/3236/ee215fc9/source/mono/external/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143 07-19 15:02:10.323 E/mono ( 3650): at Android.Runtime.JNIEnv.CallNonvirtualVoidMethod (IntPtr jobject, IntPtr jclass, IntPtr jmethod, Android.Runtime.JValue* parms) [0x00084] in /Users/builder/data/lanes/3236/ee215fc9/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:1029 07-19 15:02:10.323 E/mono ( 3650): at Android.Runtime.JNIEnv.FinishCreateInstance (IntPtr instance, IntPtr jclass, IntPtr constructorId, Android.Runtime.JValue* constructorParameters) [0x0000b] in /Users/builder/data/lanes/3236/ee215fc9/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.cs:306 07-19 15:02:10.323 E/mono ( 3650): at Android.Views.ScaleGestureDetector..ctor (Android.Content.Context context, IOnScaleGestureListener listener) [0x000d8] in /Users/builder/data/lanes/3236/ee215fc9/source/monodroid/src/Mono.Android/platforms/android-23/src/generated/Android.Views.ScaleGestureDetector.cs:477 07-19 15:02:10.323 E/mono ( 3650): at DevExpress.Mobile.DataGrid.Android.DroidGestureRecognizerService..ctor () [0x0005c] in <filename unknown>:0 07-19 15:02:10.323 E/mono ( 3650): at DevExpress.Mobile.Forms.Init () [0x0003c] in <filename unknown>:0 07-19 15:02:10.323 E/mono ( 3650): at App4Business.Droid.MainActivity.OnCreate (Android.OS.Bundle bundle) [0x000a8] in c:\Users\pasqueju\Desktop\App4Business\App\App4Business\App4Business.Droid\MainActivity.cs:48 07-19 15:02:10.323 E/mono ( 3650): at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (IntPtr jnienv, IntPtr native__this, IntPtr native_savedInstanceState) [0x00011] in /Users/builder/data/lanes/3236/ee215fc9/source/monodroid/src/Mono.Android/platforms/android-23/src/generated/Android.App.Activity.cs:2857 07-19 15:02:10.323 E/mono ( 3650): at (wrapper dynamic-method) System.Object:6d3f2cc8-3619-482a-a12e-1975032c5182 (intptr,intptr,intptr) 07-19 15:02:10.323 E/mono ( 3650): --- End of managed exception stack trace --- 07-19 15:02:10.323 E/mono ( 3650): java.lang.NullPointerException: Attempt to invoke virtual method "android.content.res.Resources android.content.Context.getResources()" on a null object reference 07-19 15:02:10.323 E/mono ( 3650): at android.view.ViewConfiguration.get(ViewConfiguration.java:364) 07-19 15:02:10.323 E/mono ( 3650): at android.view.ScaleGestureDetector.<init>(ScaleGestureDetector.java:207) 07-19 15:02:10.323 E/mono ( 3650): at android.view.ScaleGestureDetector.<init>(ScaleGestureDetector.java:189) 07-19 15:02:10.323 E/mono ( 3650): at md5c5e8c35f6309ca9ae42ed30d74b361ec.MainActivity.n_onCreate(Native Method) 07-19 15:02:10.323 E/mono ( 3650): at md5c5e8c35f6309ca9ae42ed30d74b361ec.MainActivity.onCreate(MainActivity.java:28) 07-19 15:02:10.323 E/mono ( 3650): at android.app.Activity.performCreate(Activity.java:6237) 07-19 15:02:10.323 E/mono ( 3650): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107) 07-19 15:02:10.323 E/mono ( 3650): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
My MainAcitivity:

[Activity(Label = "App4Business", Theme = "@style/AppTheme", Icon = "@drawable/icon", ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)] public class MainActivity : XFormsApplicationDroid { protected override void OnCreate(Bundle bundle) { var container = new SimpleContainer(); container.Register<IDevice>(t => AndroidDevice.CurrentDevice); container.Register<IDisplay>(t => t.Resolve<IDevice>().Display); container.Register<INetwork>(t => t.Resolve<IDevice>().Network); Resolver.SetResolver(container.GetResolver()); base.OnCreate(bundle); Xamarin.Forms.Forms.SetTitleBarVisibility(AndroidTitleBarVisibility.Default); global::Xamarin.Forms.Forms.Init(this, bundle); Telerik.XamarinForms.Common.Android.TelerikForms.Init(); CachedImageRenderer.Init(); DevExpress.Mobile.Forms.Init(); CrossPushNotification.Initialize<CrossPushNotificationListener>("XXXXXXXXX"); CrossPushNotification.Current.Register(); //This service will keep your app receiving push even when closed. DependencyService.Register<ToastNotificatorImplementation>(); ToastNotificatorImplementation.Init(this); LoadApplication(new App()); } }

The exception is thrown at the DevExpress.Mobile.Forms.Init();
When I remove this line my App is starting. But I get confusing nullpointer's in other Plugins (suchlike Connectivity)

I would appreciate any help
Julian

Is possible use SearchBar in the navigation bar using Prism.Unity.Forms?

$
0
0

I'm trying use SearchBar in the navigation bar in the content page, I'm using a master detail, but a wanna use in other page no in the master detail, my master detail navigate to other page outsite from master detail, in my other page I wanna use the SearchBar no in master detail.

How to create custom render for sfchedule calendar in xamarin forms

$
0
0


i want to convert small green dot in to big green dot like this blow


here we use sfschedule package for creating calendar , can any one tell me how to get this please tell me any one

Multiple colors in Bindable Label

$
0
0

I have a label which has its binding through a view model. Out of label's text few characters need to be in a different color. I thought of using formatted text and using different spans, but unfortunately we can't bind spans with view model. Can someone help me what to do? (my text is like " Lorem epsum ...more". The requirement is to have a different color for "...more".

How to implement an Android Service in Xamarin.Forms

$
0
0

Hi! I have an application and I want to periodically check from a web service if an item has been added to a table on a database, the new item should be added to the listview the user sees.
I'm using PCL and I did accomplish it creating a new Task and then with a timer checking every specific time but I want it to work if the app is closed too, the user should get a notification that a new item has been added.
So I was doing some research and I came across android services, the info said that the service will continue, regardless of the app state, until you tell it to stop. But I haven't found many examples and I don't know how to implement the code that I already had to the service.

This is the code that I had
Task.Run(() =>
{
Device.StartTimer(TimeSpan.FromSeconds(secs), checkUpdates);
});

bool checkUpdates()
          {
            if (isOnline)
            {
                var lastUp= Application.Current.Properties["lastUpdate"] as string;

    //the method returns a true if an item has been added
                if (service.NewItem(DateTime.Parse(lastUp)))
                {
                    var it = service.getNewItem(DateTime.Parse(lastUp));

                    Device.BeginInvokeOnMainThread(() =>
                    {    
                            notification.ShowNotification(it.Title, 1000);
                            listView.Insert(0, it);
                     }                            
                    });                  
                }
                App.Current.Properties["lastUpdate"] = DateTime.Now.ToString();
            }
            return true;
        }

This is the code that works when the app is open, and I'm trying to use dependecy services to consume the service in my PCL. Here's what I've got so far:

     public interface IService
        {
            void Start();
        }

      [Service]
        public class DependentService : Service, IService
        {
            public void Start()
            {
                var intent = new Intent(Android.App.Application.Context, typeof(DependentService));
                Android.App.Application.Context.StartService(intent);
            }

            public override IBinder OnBind(Intent intent)
            {
                return null;
            }

            public override StartCommandResult OnStartCommand(Intent intent, StartCommandFlags flags, int startId)
            {
                // From shared code or in your PCL


                return StartCommandResult.NotSticky;
            }
        }

The problem is that I don't know how to implement the same code that I had in the timer here. Can someone please help?


Filling a sectioned RecyclerView using a SortedDictionary, ViewHolders under section not showing

$
0
0

Hi guys! I've been trying to fill a RecyclerView using a SortedDictionary<DateTime, List<Event>>. Events in this SortedDictionary need to be sectioned by DateTime. My current solution displays the headers just fine, but the events under the DateTime key are not shown. My initial approach has been to fire OnCreateViewHolder() and OnBindViewHolder() manually using the CreateViewHolder() and BindViewHolder() functions and handle the creation of both ViewHolder types inside the event listeners. I don't seem to be forgetting anything when I compare the process for the placement of the section headers with that of the event ViewHolders, but I must be missing something that causes the views for the events not to show. I hope you guys can help me with this.

Here's the code for the Adapter that I made:

public class EventsRecyclerViewAdapter : RecyclerView.Adapter {
    public SortedDictionary<DateTime, List<Event>> EventDictionary { get; set; }
    private const int TYPE_HEADER = 0;
    private const int TYPE_EVENT = 1;
    ViewGroup viewGroupHelper;

    public override int ItemCount => this.EventDictionary.Count;

    public override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType) {
        LayoutInflater layoutInflater = LayoutInflater.From(parent.Context);
        View itemView;
        viewGroupHelper = parent;
        if (viewType == TYPE_HEADER) {
            itemView = layoutInflater.Inflate(Resource.Layout.view_eventlist_header, parent, false);
            return new HeaderViewHolder(itemView);
        }
        itemView = layoutInflater.Inflate(Resource.Layout.view_eventlist_event, parent, false);
        return new EventViewHolder(itemView);
    }

    public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        if (holder is EventViewHolder) {
            EventViewHolder eViewHolder = holder as EventViewHolder;
            eViewHolder.EventTitle.Text = "Test";
            return;
        }
        HeaderViewHolder hViewHolder = holder as HeaderViewHolder;
        DateTime eventStartGroup = EventDictionary.Keys.ElementAt(position);
        hViewHolder.EventStartGroup.Text = (DateTime.Today == eventStartGroup) ? "Today" : eventStartGroup.ToString("dd MMMM yyyy");
        List<Event> eventsUnderDate = EventDictionary.Values.ElementAt(position);
        FillEventsUnderDate(viewGroupHelper, position, eventsUnderDate);
    }

    private void FillEventsUnderDate(ViewGroup parent, int position, List<Event> events) {
        foreach (Event @event in events) {
            EventViewHolder holder = CreateViewHolder(parent, TYPE_EVENT) as EventViewHolder;
            BindViewHolder(holder, position++);
        }
    }

    private class HeaderViewHolder : RecyclerView.ViewHolder {
        public TextView EventStartGroup { get; set; }
        public HeaderViewHolder(View itemView) : base(itemView) {
            EventStartGroup = itemView.FindViewById<TextView>(Resource.Id.eventlist_header);
        }
    }

    private class EventViewHolder : RecyclerView.ViewHolder {
        public TextView EventTitle { get; set; }
        public EventViewHolder(View itemView) : base(itemView) {
            EventTitle = itemView.FindViewById<TextView>(Resource.Id.eventlist_event);
        }
    }
}

Thanks in advance!

How to implement an Android Service in Xamarin.Forms

$
0
0

Hi! I have an application and I want to periodically check from a web service if an item has been added to a table on a database, the new item should be added to the listview the user sees.
I'm using PCL and I did accomplish it creating a new Task and then with a timer checking every specific time but I want it to work if the app is closed too, the user should get a notification that a new item has been added.
So I was doing some research and I came across android services, the info said that the service will continue, regardless of the app state, until you tell it to stop. But I haven't found many examples and I don't know how to implement the code that I already had to the service.

This is the code that I had
Task.Run(() =>
{
Device.StartTimer(TimeSpan.FromSeconds(secs), checkUpdates);
});

bool checkUpdates()
          {
            if (isOnline)
            {
                var lastUp= Application.Current.Properties["lastUpdate"] as string;

    //the method returns a true if an item has been added
                if (service.NewItem(DateTime.Parse(lastUp)))
                {
                    var it = service.getNewItem(DateTime.Parse(lastUp));

                    Device.BeginInvokeOnMainThread(() =>
                    {    
                            notification.ShowNotification(it.Title, 1000);
                            listView.Insert(0, it);
                     }                            
                    });                  
                }
                App.Current.Properties["lastUpdate"] = DateTime.Now.ToString();
            }
            return true;
        }

This is the code that works when the app is open, and I'm trying to use dependecy services to consume the service in my PCL. Here's what I've got so far:

     public interface IService
        {
            void Start();
        }

      [Service]
        public class DependentService : Service, IService
        {
            public void Start()
            {
                var intent = new Intent(Android.App.Application.Context, typeof(DependentService));
                Android.App.Application.Context.StartService(intent);
            }

            public override IBinder OnBind(Intent intent)
            {
                return null;
            }

            public override StartCommandResult OnStartCommand(Intent intent, StartCommandFlags flags, int startId)
            {
                // From shared code or in your PCL


                return StartCommandResult.NotSticky;
            }
        }

The problem is that I don't know how to implement the same code that I had in the timer here. Can someone please help?

Filling a sectioned RecyclerView using a SortedDictionary, ViewHolders under section not showing

$
0
0

Hi guys! I've been trying to fill a RecyclerView using a SortedDictionary<DateTime, List<Event>>. Events in this SortedDictionary need to be sectioned by DateTime. My current solution displays the headers just fine, but the events under the DateTime key are not shown. My initial approach has been to fire OnCreateViewHolder() and OnBindViewHolder() manually using the CreateViewHolder() and BindViewHolder() functions and handle the creation of both ViewHolder types inside the event listeners. I don't seem to be forgetting anything when I compare the process for the placement of the section headers with that of the event ViewHolders, but I must be missing something that causes the views for the events not to show. I hope you guys can help me with this.

Here's the code for the Adapter that I made:

public class EventsRecyclerViewAdapter : RecyclerView.Adapter {
    public SortedDictionary<DateTime, List<Event>> EventDictionary { get; set; }
    private const int TYPE_HEADER = 0;
    private const int TYPE_EVENT = 1;
    ViewGroup viewGroupHelper;

    public override int ItemCount => this.EventDictionary.Count;

    public override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType) {
        LayoutInflater layoutInflater = LayoutInflater.From(parent.Context);
        View itemView;
        viewGroupHelper = parent;
        if (viewType == TYPE_HEADER) {
            itemView = layoutInflater.Inflate(Resource.Layout.view_eventlist_header, parent, false);
            return new HeaderViewHolder(itemView);
        }
        itemView = layoutInflater.Inflate(Resource.Layout.view_eventlist_event, parent, false);
        return new EventViewHolder(itemView);
    }

    public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        if (holder is EventViewHolder) {
            EventViewHolder eViewHolder = holder as EventViewHolder;
            eViewHolder.EventTitle.Text = "Test";
            return;
        }
        HeaderViewHolder hViewHolder = holder as HeaderViewHolder;
        DateTime eventStartGroup = EventDictionary.Keys.ElementAt(position);
        hViewHolder.EventStartGroup.Text = (DateTime.Today == eventStartGroup) ? "Today" : eventStartGroup.ToString("dd MMMM yyyy");
        List<Event> eventsUnderDate = EventDictionary.Values.ElementAt(position);
        FillEventsUnderDate(viewGroupHelper, position, eventsUnderDate);
    }

    private void FillEventsUnderDate(ViewGroup parent, int position, List<Event> events) {
        foreach (Event @event in events) {
            EventViewHolder holder = CreateViewHolder(parent, TYPE_EVENT) as EventViewHolder;
            BindViewHolder(holder, position++);
        }
    }

    private class HeaderViewHolder : RecyclerView.ViewHolder {
        public TextView EventStartGroup { get; set; }
        public HeaderViewHolder(View itemView) : base(itemView) {
            EventStartGroup = itemView.FindViewById<TextView>(Resource.Id.eventlist_header);
        }
    }

    private class EventViewHolder : RecyclerView.ViewHolder {
        public TextView EventTitle { get; set; }
        public EventViewHolder(View itemView) : base(itemView) {
            EventTitle = itemView.FindViewById<TextView>(Resource.Id.eventlist_event);
        }
    }
}

Thanks in advance!

iOS application rejected by apple

$
0
0

Hi All,

I have just submited my iOS application on App Store but they have rejected because of my application has not support IPV6 enable network.

My app has developed in Xamarin.form.

can any one can help me how to I resolve that?

Bug: Xamarin.Froms ControlTemplate with ToolbarItem does not work

$
0
0

Description
Hello.

Basic Setup: I want to have a Xamarin.Forms.ToolbarItem and a Xamarin.Forms.ControlTemplate in a ContentPage with a ViewModel. The ToolbarItem has a Command which should be executed on Tap.

Problem: The ToolbarItem.Command has a Binding to the ViewModel.Command which does not work.
When I start and click on the ToolbarItem it does not work.

Can someone tell me if I am missing something here, or if this is a real issue?
I am not very experienced with Bug reports so if I need to add/change something pleas tell me.

Steps to Reproduce
Create .net standard Project with Prism.Template
Choose Android Project for execution
Create a new Page with new Item Prism Content Page
Navigate at startup to that page
App.xaml.cs
await NavigationService.NavigateAsync("NavigationPage/DummyPage");
Insert the Code
DummTestPage

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http:  //xamarin.com/schemas/2014/forms"
             xmlns:x="http:  //schemas.microsoft.com/winfx/2009/xaml"
             xmlns:prism="clr-namespace:Prism.Mvvm;assembly=Prism.Forms"
             prism:ViewModelLocator.AutowireViewModel="True"
             x:Class="TestNetCore.Views.DummyPage">
    <ContentPage.ControlTemplate>
        <ControlTemplate>
            <StackLayout>
                <Grid>
                    <BoxView BackgroundColor="Lime" />
                    <Label>I TEST ControlTemplate</Label>
                </Grid>
                <ContentPresenter />
            </StackLayout>
        </ControlTemplate>
    </ContentPage.ControlTemplate>
    <ContentPage.ToolbarItems>
        <ToolbarItem Text="A" Clicked="MenuItem_OnClicked" Command="{Binding ToolbarTappedCommand}"></ToolbarItem>
    </ContentPage.ToolbarItems>
    <StackLayout>
        <Label FontSize="28">I AM AN EMPTY PAGE</Label>
    </StackLayout>
</ContentPage>

DummTestPage.cs

        public partial class DummyPage : ContentPage
    {
        #region Public Constructors

        public DummyPage()
        {
            InitializeComponent();
        }

        #endregion Public Constructors

        #region Private Methods

        private void MenuItem_OnClicked(object sender, EventArgs e)
        {
        }

        #endregion Private Methods
    }

DummyPageViewModel

public class DummyPageViewModel : BindableBase
    {
        #region Public Constructors

        public DummyPageViewModel()
        {
            ToolbarTappedCommand = new NewCommand();
        }

        #endregion Public Constructors

        #region Public Properties

        public ICommand ToolbarTappedCommand { get; set; }

        #endregion Public Properties
    }

    public class NewCommand : ICommand
    {
        #region Public Events

        public event EventHandler CanExecuteChanged;

        #endregion Public Events

        #region Public Methods

        public bool CanExecute(object parameter)
        {
            return true;
        }

        public void Execute(object parameter)
        {
        }

        #endregion Public Methods
    }

Set a Breakpoint to
NewCommand.CanExecute
NewCommand.Execute
MenuItem_OnClicked
Execute Programm

Expected Behavior
Execute NewCommand.CanExecute on startup
Execute NewCommand.Execute on Tap
Execute MenuItem_OnClicked on Tap

Actual Behavior
Execute MenuItem_OnClicked on Tap

Basic Information
Version with issue: Prism Template Pack 2.0.8 | Prism.Unit.Forms 7.0.0.362
Last known good version:
Xamarin.Forms version: 2.4.0.280555
IDE: VS17 15.6.1
Screenshots
Reproduction Link
What exactly do i need to do here?

Solutions
Removeing the lines in the XAML

xmlns:prism="clr-namespace:Prism.Mvvm;assembly=Prism.Forms"
prism:ViewModelLocator.AutowireViewModel="True"

Every thing works as expected now
2. Removeing the ControlTemplate in the XMAL

    <ContentPage.ControlTemplate>
        <ControlTemplate>
            <StackLayout>
                <Grid>
                    <BoxView BackgroundColor="Lime" />
                    <Label>I TEST ControlTemplate</Label>
                </Grid>
                <ContentPresenter />
            </StackLayout>
        </ControlTemplate>
    </ContentPage.ControlTemplate>

Works but you dont have a controlTemplate now :(
3. Switching ControlTemplate and ToolbarItems

    <ContentPage.ToolbarItems>
        <ToolbarItem Text="A" Clicked="MenuItem_OnClicked" Command="{Binding ToolbarTappedCommand}"></ToolbarItem>
    </ContentPage.ToolbarItems>
    <ContentPage.ControlTemplate>
        <ControlTemplate>
            <StackLayout>
                <Grid>
                    <BoxView BackgroundColor="Lime" />
                    <Label>I TEST ControlTemplate</Label>
                </Grid>
                <ContentPresenter />
            </StackLayout>
        </ControlTemplate>
    </ContentPage.ControlTemplate>

CanExecute is not called at beginning
And if you set the ControlTemplate as StaticRessouce (which is what I like to do) this does not work
ControlTemplate="{StaticResource BaseControlTemplate}"

Tags
Xamarin.Froms ControlTemplate ToolbarItem Binding not working

Viewing all 58056 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>