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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

use Combobox in a ContentView and it stop showing dropdown

Thread ID:

Created:

Updated:

Platform:

Replies:

142226 Jan 23,2019 10:18 AM UTC Jan 25,2019 06:18 AM UTC Xamarin.Forms 3
loading
Tags: SfComboBox
mohammad kamali
Asked On January 23, 2019 10:18 AM UTC

Hi syncfusion team.
I'm using SfComboBox in a ContentView so that i can change its appeance. so the xaml code is like this

<ContentView xmlns="http://xamarin.com/schemas/2014/forms" 
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="App1.App.Controls.CustomComboBox"
             xmlns:controls="clr-namespace:App1.App.Controls"
             xmlns:control="clr-namespace:App1.App.Controls"
             xmlns:comboBox="clr-namespace:Syncfusion.XForms.ComboBox;assembly=Syncfusion.SfComboBox.XForms"
             x:Name="customComboBox">
    <ContentView.Content>
        <comboBox:SfComboBox BindingContext="{x:Reference customComboBox}" Text="{Binding Text}" DataSource="{Binding DataSource}" DisplayMemberPath="{Binding DisplayMemberPath}"/>
    </ContentView.Content>
</ContentView>

and in c# code I've created Bindable properties like below


using System.Collections;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;

namespace App1.App.Controls
{
    public partial class CustomComboBox : ContentView
    {
        public CustomComboBox()
        {
            InitializeComponent();
        }

        public static readonly BindableProperty BorderColorProperty = BindableProperty.Create(nameof(BorderColor), typeof(Color), typeof(SanaapComboBox), Color.FromHex("#e2e2e2"), BindingMode.TwoWay);
        public Color BorderColor
        {
            get => (Color)GetValue(BorderColorProperty);
            set => SetValue(BorderColorProperty, value);
        }

        public static readonly BindableProperty TextProperty = BindableProperty.Create(nameof(Text), typeof(string), typeof(SanaapComboBox), null, BindingMode.TwoWay);
        public string Text
        {
            get => (string)GetValue(TextProperty);
            set => SetValue(TextProperty, value);
        }

        public static readonly BindableProperty FontFamilyProperty = BindableProperty.Create(nameof(FontFamily), typeof(string), typeof(SanaapComboBox), null, BindingMode.TwoWay);
        public string FontFamily
        {
            get => (string)GetValue(FontFamilyProperty);
            set => SetValue(FontFamilyProperty, value);
        }

        public static readonly BindableProperty TextColorProperty = BindableProperty.Create(nameof(TextColor), typeof(Color), typeof(SanaapComboBox), Color.Black, BindingMode.TwoWay);
        public Color TextColor
        {
            get => (Color)GetValue(TextColorProperty);
            set => SetValue(TextColorProperty, value);
        }

        public static readonly BindableProperty FontSizeProperty = BindableProperty.Create(nameof(FontSize), typeof(int), typeof(SanaapComboBox), 15, BindingMode.TwoWay);
        public int FontSize
        {

            get => (int)GetValue(FontSizeProperty);
            set => SetValue(FontSizeProperty, value);
        }

        public static readonly BindableProperty DataSourceProperty = BindableProperty.Create(nameof(DataSource), typeof(IEnumerable), typeof(SanaapComboBox), null, BindingMode.TwoWay);
        public IEnumerable DataSource
        {
            get => (IEnumerable)GetValue(DataSourceProperty);
            set => SetValue(DataSourceProperty, value);
        }

        public static readonly BindableProperty AllowFilteringProperty = BindableProperty.Create(nameof(AllowFiltering), typeof(bool), typeof(SanaapComboBox), false, BindingMode.TwoWay);
        public bool AllowFiltering
        {
            get => (bool)GetValue(AllowFilteringProperty);
            set => SetValue(AllowFilteringProperty, value);
        }

        public static readonly BindableProperty IsEditableModeProperty = BindableProperty.Create(nameof(IsEditableMode), typeof(bool), typeof(SanaapComboBox), false, BindingMode.TwoWay);
        public bool IsEditableMode
        {
            get => (bool)GetValue(IsEditableModeProperty);
            set => SetValue(IsEditableModeProperty, value);
        }

        public static readonly BindableProperty DisplayMemberPathProperty = BindableProperty.Create(nameof(DisplayMemberPath), typeof(string), typeof(SanaapComboBox), string.Empty, BindingMode.TwoWay);
        public string DisplayMemberPath
        {
            get => (string)GetValue(DisplayMemberPathProperty);
            set => SetValue(DisplayMemberPathProperty, value);
        }

        public static readonly BindableProperty SelectedItemProperty = BindableProperty.Create(nameof(SelectedItem), typeof(object), typeof(SanaapComboBox), null, BindingMode.TwoWay);
        public object SelectedItem
        {
            get => GetValue(SelectedItemProperty);
            set => SetValue(SelectedItemProperty, value);
        }
    }
}

But when i tried to bind DataSource to it it wont show the DropDownView
what do you think?


Mugundhan Saravanan [Syncfusion]
Replied On January 24, 2019 01:23 PM UTC

Hi Mohammad kamali,

Greetings from Syncfusion.

Query: “use Combobox in a ContentView and it stop showing dropdown”

We have analyzed the reported requirement. We have prepared a sample as per the given code snippet and it is working expected. Please have the sample from the following link

Sample: http://www.syncfusion.com/downloads/support/forum/142226/ze/SfComboBoxSample_31055535611  

In that sample we have apply all the codes you have used but additionally we have used the SfComboBox inside the StackLayout as given by
 
<ContentView.Content> 
        <StackLayout> 
            <comboBox:SfComboBox BindingContext="{x:Reference customComboBox}" HeightRequest="50" x:Name="combobox" Text="Text" DataSource="{Binding DataSource}" DisplayMemberPath="{Binding DisplayMemberPath}" /> 
        </StackLayout>
   </ContentView.Content> 

If you still reproduce the reported issue means, please revert us by modifying the sample based on your application along with replication procedure. This will be helpful for us to investigate further and provide you a better solution at the earliest.

Regards,
Mugundhan S.

mohammad kamali
Replied On January 24, 2019 01:35 PM UTC

Thanks 
this works

Dhanasekar R [Syncfusion]
Replied On January 25, 2019 06:18 AM UTC

Hi Mohammad kamali, 
 
Glad that the issue has been resolved. Please let us know if any further assistance on this. 
 
Regards, 
Dhanasekar  


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;