RadMultiColumnComboBox show selected item as a combination of multiple properties in a class

1 Answer 135 Views
AutoCompleteBox ComboBox GridView MultiColumnComboBox
ofir
Top achievements
Rank 1
ofir asked on 25 Jan 2023, 01:59 PM | edited on 25 Jan 2023, 02:01 PM
I have the following class

Class My Class
Class MyClass()
{
   public int Var1 {get; set; }
   public int Var2 {get; set; }
}
i want the selected item to show {var1}/{var2}
for now im doing (for now) is
DisplayMemberPath = "Var1"
but because its a String and a Dependency property i cannot attach a MultiBinding
and RadMultiColumnComboBox  does not have itemTemplate property
how can i achieve it

P.S 
I want the same behavior for the tooltip

p.s 2
i also want to center the selected text but it seems HorizontalContentAlignment  is not working


Thanks in advance

1 Answer, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 30 Jan 2023, 10:59 AM

Hello Ofir,

To display the needed value in the cell, you can use the CellTemplate property of the columns. This will allow you also to have more control over the text's alignment. If you don't use the CellTemplate, you can center the text using the TextAlignment property of the columns.

In case you don't want to use the CellTemplate for some reason, you can get the desired effect by exposing an extra property in your row's view model that holds both values .

public class MyClass()
{
   public int Var1 {get; set; }
   public int Var2 {get; set; }
   
   public string Var1And2
   {
		get { return string.Format("{0}/{1}", this.Var1, this.Var2); }
   }
}

DisplayMemberPath = "Var1And2"

For the tooltip, you can use the ToolTipTemplate property of the columns.

I hope that information helps.

Regards,
Martin Ivanov
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

ofir
Top achievements
Rank 1
commented on 01 Feb 2023, 05:43 AM | edited

Hi Martin thank you for the answer
but i don't want to change the cell template or the cells(that's i already figured out)
i want to change the properties i asked for the 
AutoComplete box part
also note that im doing SelectionBoxesVisibility = false , because i dont want the chip behavior(text with icon on the top left) 

P.S 
i do not want to override any tempaltes if possible


 

 

Martin Ivanov
Telerik team
commented on 01 Feb 2023, 09:37 AM

In that case, you can use the approach with the combined property. You can see this idea in the attached project. I hope it helps.
ofir
Top achievements
Rank 1
commented on 01 Feb 2023, 10:28 AM

thanks you very much

and what about the HorizontalContentAlignment  it seems as its not doing anything to the AutoComplete 
Martin Ivanov
Telerik team
commented on 01 Feb 2023, 11:57 AM

The autocompletebox element that shows the search text doesn't support horizontal alignment. This is because its textbox element is hosted in a special panel that arranges it at a fixed position in the viewport. In this case, this is the left part of the autocompletebox. Currently, there is no good entry point that allows you to change the text position. One way to do so, is to modify the ControlTemplate of the SearchAutoCompleteBox control which is in the ControlTemplate of the RadMultiColumnComboBox.
ofir
Top achievements
Rank 1
commented on 01 Feb 2023, 04:36 PM

with blend 2022 im trying to edit template its also shows me "Create empty"
Martin Ivanov
Telerik team
commented on 02 Feb 2023, 10:10 AM

I would suggest you to copy the needed resources from the .xaml files provided with the Telerik installation folder. This is because the VS/Blend Designer's extraction tool is not always working and also sometimes it is not very accurate in extraction of templates, as it may skip or alter some property settings.
Tags
AutoCompleteBox ComboBox GridView MultiColumnComboBox
Asked by
ofir
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Share this question
or