SfCombobox Itemtemplate Customization


Please help me to implement space or separator between items in Sfcombox i used various technique but I couldn't able to succeed

9 Replies 1 reply marked as answer

AS Anandraj Selvam Syncfusion Team April 7, 2021 06:42 AM UTC

Hi Shahid Abbas, 
  
We have validated the reported query and you can resolve this issue by using MultiSelectMode as Delimiter. The selected items can be divided with a desired character given for a delimiter. 
  
  
Note: It supports for all platforms. 
  
Please let us know if you have any other concerns. 
  
Regards, 
Anand Raj S. 



SA Shahid Abbas April 7, 2021 08:46 AM UTC

My Issue not about MultiSelectMode. My issue about itemtemplate gap between items in list. 




AS Anandraj Selvam Syncfusion Team April 8, 2021 08:53 AM UTC

Hi Shahid Abbas,  
  
Sorry for the inconvenience caused. 
  
We have validated the reported query and you can resolve this issue by using DropDownItemHeight to provide space between items or you can customize by providing line between suggestion items as below code snippet: 
  
 
XAML 
 
<combobox:SfComboBox 
            x:Name="comboBox" 
            DataSource="{Binding EmployeeCollection}" 
            DisplayMemberPath="Name" 
            HeightRequest="40"> 
            <combobox:SfComboBox.ItemTemplate> 
                <DataTemplate> 
                    <StackLayout HeightRequest="100"> 
                        <StackLayout Orientation="Horizontal" VerticalOptions="Center"> 
                            <Image Source="User.png" WidthRequest="30" /> 
                            <Label Text="{Binding Name}" WidthRequest="150" /> 
                        </StackLayout> 
                        <BoxView 
                            BackgroundColor="Black" 
                            HeightRequest="2" 
                            HorizontalOptions="FillAndExpand" /> 
                    </StackLayout> 
                </DataTemplate> 
            </combobox:SfComboBox.ItemTemplate> 
        </combobox:SfComboBox> 
 
     
Please have the sample and screenshot for your reference.  
  
  
Screenshot: 
  
 
 
Please revert us for further investigation. 
   
Regards,  
Anand Raj S. 


Marked as answer

SA Shahid Abbas April 9, 2021 05:09 AM UTC

HeightRequest doesn't affect the code. if its changed no change affects in design


SS Suganya Sethuraman Syncfusion Team April 12, 2021 05:24 AM UTC

Hi Shahid Abbas,

We have checked DropDownItemHeight API. This is working fine. Please have the code snippet for your reference,

Code snippet
 
<StackLayout 
        Padding="30" 
        HorizontalOptions="Start" 
        VerticalOptions="Start"> 
    <combobox:SfComboBox 
            x:Name="comboBox" 
            DataSource="{Binding EmployeeCollection}" 
            DisplayMemberPath="Name" 
            DropDownItemHeight="80" 
            HeightRequest="40"> 
        <combobox:SfComboBox.ItemTemplate> 
            <DataTemplate> 
                <StackLayout> 
                    <StackLayout Orientation="Horizontal" VerticalOptions="Center"> 
                        <Image Source="User.png" WidthRequest="30" /> 
                        <Label Text="{Binding Name}" WidthRequest="150" /> 
                    </StackLayout> 
                    <BoxView 
                            BackgroundColor="Black" 
                            HeightRequest="2" 
                            Margin="-10,0,0,0" 
                            VerticalOptions="EndAndExpand" 
                            HorizontalOptions="FillAndExpand" /> 
                </StackLayout> 
            </DataTemplate> 
        </combobox:SfComboBox.ItemTemplate> 
    </combobox:SfComboBox> 
</StackLayout> 

Please check and let us know if you have any concerns.

Regards,
Suganya Sethuraman.
 



SA Shahid Abbas April 17, 2021 06:09 AM UTC

Actually, we tried code snippet on my code, but there were no changes occur I will post my Combobox screenshot and code snippet here.We upload 3 screenshots first(1) we needed second(2) we got after putting the code and code snippet

Attachment: docs_bdc64bf1.rar


SS Suganya Sethuraman Syncfusion Team April 19, 2021 11:14 AM UTC

Hi Shahid,

We have checked the screenshots. We have achieved your requirement using DropDownItemHeight property of SfComboBox as below code snippet,

Code snippet
 
<combobox:SfComboBox 
            x:Name="comboBox" 
            AllowFiltering="True" 
            DataSource="{Binding EmployeeCollection}" 
            DisplayMemberPath="Name" 
            DropDownItemHeight="60" 
            HeightRequest="40" 
            IsEditableMode="True" 
            MaximumDropDownHeight="300" 
            MultiSelectMode="None" 
            SelectedItem="{Binding SelectedItem, Mode=TwoWay}" 
            SuggestionMode="Contains"> 
            <combobox:SfComboBox.ItemTemplate> 
                <DataTemplate> 
                    <Grid> 
                        <Grid.ColumnDefinitions> 
                            <ColumnDefinition Width="20" /> 
                            <ColumnDefinition Width="Auto" /> 
                        </Grid.ColumnDefinitions> 
                        <Frame 
                            Grid.Column="0" 
                            Margin="5,0" 
                            Padding="0" 
                            BackgroundColor="Red" 
                            CornerRadius="5" 
                            HeightRequest="10" 
                            HorizontalOptions="Start" 
                            VerticalOptions="Center" 
                            WidthRequest="10" /> 
                        <Label 
                            Grid.Column="1" 
                            FontSize="12" 
                            HorizontalOptions="FillAndExpand" 
                            Text="{Binding Name}" 
                            TextColor="Blue" 
                            VerticalOptions="Center" /> 
                    </Grid> 
                </DataTemplate> 
            </combobox:SfComboBox.ItemTemplate> 
        </combobox:SfComboBox> 

Screenshot
 
 
Please have the sample for your reference,

Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/ComboBox_Drop-582924047

Please check and let us know if you have any queries.

Regards,
Suganya Sethuraman.


 



LI Libin April 21, 2021 08:06 AM UTC

Hi Suganya,

Thank you for the reply. However, what we are trying to achieve is to allow the list items to have a dynamic, variable height based on the content. For example, one item may have 20 characters and the other may have 500 characters.


SS Suganya Sethuraman Syncfusion Team April 22, 2021 11:04 AM UTC

Hi Libin,

Currently, we don’t have direct support for your requirement. So, we have considered “Provide dynamic height support based on the content of dropdown item in SfComboBox” as a feature and logged this as a feature request, and you can track the status of this feature implement through below link

Feedback link: https://www.syncfusion.com/feedback/24607

Please cast your vote to make it count. We will prioritize the features every release based on the demands and we do not have an immediate plan to implement this feature since we committed with already planned work. So, this feature will be available in any of our upcoming releases.

If you have any more specifications/suggestions to the feature request, you can add it as a comment in the portal.

Regards,
Suganya Sethuraman.
 


Loader.
Up arrow icon