We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Unable to find the height and width property of the appointments that are loaded in

Hey,

Great update I am very impressed with the improvements! While we are at the subject of the update I got a qeustion.

You have changed the ''OnAppointmentLoadedEvent'' which is fine my app is still working after changing some code. But the thing is I had a custom view (a button) loaded instead of the default render that you provide.

This was necessary to load a image when the appointment itself was a group appointment. Only the following problem occurs:

The button does not fully expands and fills the size this is probably because it does not know how much size it has.

So I would like to know how do I acces the height and width value? So I can set these as height and width-reqeust for my button :)?


Here is part of my code so you have a better understanding about my needs:

C#
   public ICommand OnAppointmentLoadedCommand {

            get {
                return new Command<AppointmentLoadedEventArgs>((args) =>
                {
                   
                    var test4 = args.Bounds;
                    if (args.appointment is BNScheduleAppointment)
                    {
                        var loadedAppointment = (BNScheduleAppointment)args.appointment;
              
                        
          

                        ExtendedBNButton appointmentButton = new ExtendedBNButton()
                        {
                            Text = loadedAppointment.Subject,
                            TextColor = Color.Black,
                            BorderWidth = 2,
                            BorderRadius = 2,
                            BorderColor = Color.Red,
                            BackgroundColor = loadedAppointment.Color,
                            VerticalContentAlignment = TextAlignment.Center,
                            HorizontalContentAlignment = TextAlignment.Start,
                            HorizontalOptions = LayoutOptions.FillAndExpand,
                            VerticalOptions = LayoutOptions.FillAndExpand,
                            Command = OnAppointmentTappedCommand,
                            CommandParameter = args.appointment as BNScheduleAppointment,
                        };
                        //var test = args.Bounds.Size.Height;
                        //var test2 = args.Bounds.Size.Width;
                        //appointmentButton.HeightRequest = args.Bounds.Height;
                        //appointmentButton.WidthRequest = args.Bounds.Width;
                        // todo add more    
                        if (loadedAppointment.IsGroup)
                        {
                            appointmentButton.Image = "Group.png";
                        }
                        args.view = appointmentButton;
                     


                    }


                });
            }
        }

I have left some of the testing inside the code to show you what I have tried as a possible solutions :)


Cheers and thanks in advance!

Luuk

11 Replies

SP Subburaj Pandian Veluchamy Syncfusion Team February 16, 2017 09:12 AM UTC

Hi Luuk, 

  

Thank you for update.  

  

Based on the provided information, we have checked your requirement of positioning the CustomView of ScheduleAppointment in the OnAppointmentLoaded event in Xamarin Forms (iOS). As per the behavior, CustomView will not positioned based on given height in the View and it can be achieved by setting Margin to CustomView add in the ParentView. For example, if you are setting “Button” as a CustomView, you can add the Button in the StackLayout and by setting Margin to the Button you can positioned the Button based on your requirement. Please refer the below code, 

  

[c#] 

  

button.Text = "click";
button.TextColor = Color.Blue;
button.BackgroundColor = Color.Green;
if (Device.OS == TargetPlatform.iOS)
{
   button.Margin = new Thickness(10101010);
 

   button.HeightRequest = 40;
   button.WidthRequest = 30;

}
button.Image = "user.png";
stack.Children.Add(button);
args.view = stack;
 

  

  

If the given solution doesn’t meet your requirement, could you please revert us back with more information about your query? It will be helpful for us to analyze on it and provide you a better solution. 


Regards, 

Subburaj Pandian V. 




LU Luuk February 16, 2017 11:59 AM UTC

Hey,

Ok thanks for the code example, did not try it yet but I want to add a picture showcasing the issue:


Take a look at this. Even though I set the button to FillAndExpand it still does not expand at all :) I want it to be the size of the original appointment when not using a custom view.


Cheers,

Luuk


SP Subburaj Pandian Veluchamy Syncfusion Team February 17, 2017 08:38 AM UTC

Hi Luuk, 

  

Thank you for the update. 

  

We have checked your requirement of Setting the CustomView to the entire Appointment in Android and it can be achieved by setting Bounds Width and Height to the CustomView Width and Height. Please refer the below code example, 

  

[c#] 

  

if (Device.OS == TargetPlatform.Android)
{
    button.WidthRequest = args.Bounds.Width;
    button.HeightRequest = args.Bounds.Height;
}
 

  

  

In the previous update we have provided code example for setting CustomView within the Appointment in iOS, could you please check this solution and let us know, if you have any further query on this. 

  

Regards, 

Subburaj Pandian V. 




LU Luuk February 17, 2017 09:33 AM UTC

Hey,

I have tried your solution with the args.bound.width etc.

This does not work it will size the appointment to sizes beyond the bounds.

Here's a screenshot of the result:




LU Luuk replied to Luuk February 17, 2017 09:34 AM UTC

Hey,

I have tried your solution with the args.bound.width etc.

This does not work it will size the appointment to sizes beyond the bounds.

Here's a screenshot of the result:



Here's the link link to error


so how am I able to get the correct height and width value?


Cheers,

Luuk 


SP Subburaj Pandian Veluchamy Syncfusion Team February 20, 2017 08:49 AM UTC

Hi Luuk, 

  

Thank you for the update. 

  

We have checked the mentioned query with setting CustomView to the ScheduleAppointment using Schedule OnAppoitmentLoaded event in Xamarin Forms (Android). As per the behaviour of button in Xamarin, button has default padding and the border radius is 5. So that while setting button as CutsomView it has not occupying entire size for rendering. It can be resolved by setting negative padding (-10) to the Button, please refer the below code example. 

  

[c#] 

button.Margin = new Thickness(-10, -10, -10, -10);  

  

  

If the given solution doesn’t meet your requirement, could you please revert us by modifying the provided sample with more information about your query? It will be helpful for us to analyze on it and provide you a better solution.   

  

Regards,   

Subburaj Pandian V.   




LU Luuk February 21, 2017 12:47 PM UTC

Hey,

I would like to followup on the suggestion that you made about the thickness. The solution does not fix the issue with the button not fully occupying the space it. It does however work on iOS so I don't know why Android does not know what size the button should have.

Here's a picture after applying the margin suggestion:


I hope you can help me find the right solution to my problem !


Cheers and thanks in advance,

Luuk Jongebloet


LU Luuk February 21, 2017 12:48 PM UTC

Also when settings the bounds + the thickness the button will still showup way too big. So how is the size of a appointment calculated?




SP Subburaj Pandian Veluchamy Syncfusion Team February 22, 2017 12:34 PM UTC

Hi Luuk, 


We have checked, the provided code example has resolved the issue with setting CustomView size to the ScheduleAppointment using Schedule OnAppoitmentLoaded event in Xamarin Forms (Android) and we are unable to reproduce the issue from our side. We have prepared sample based on this scenario, please find the below sample, 


Sample link: Appointment_CustomView
 


In the sample, We have ScheduleAppointments and set the CustomView as Button in the StackLayout in OnAppointmentLoaded event, and it has occupying the entire size of the Appointment. We have attached screenshot of the output along with the sample.  


If the given sample doesn't meet your required scenario, could you please revert to us by modifying the provided sample with more information (device details if the sample meet your requirement), it will be helpful for us to check on it and provide you the better solution.  


Regards, 

Subburaj Pandian V 






LU Luuk February 23, 2017 11:04 AM UTC

Hey,

Well I have opened and run your solution. When run it does show the bug I am talking about, I have modified nothing in the given sample.

This is a image taken:



For your information the emulator info:

Api level 23
Android 6.0

The link has all the remaining information that you might need. And just to be sure I am also sending the project back with your sample.


Thanks in advance,

Luuk 




Attachment: Appointment_CustomView1233979774_10680443.rar


SP Subburaj Pandian Veluchamy Syncfusion Team February 27, 2017 09:08 AM UTC

Hi Luuk, 
  
We have created a new support incident under your account to track the status of this query with CustomView. Please log on to our support website to check for further updates. 
  
  
Regards, 
 
Subburaj Pandian V.   


Loader.
Live Chat Icon For mobile
Up arrow icon