This is a migrated thread and some comments may be shown as answers.

MultiSelect ComboBox SelectionBoxTemplate binding issue

2 Answers 131 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Abdul
Top achievements
Rank 1
Abdul asked on 02 Aug 2015, 12:52 PM

To illustrate MultiSelectComboBox, I am using some forum posted code.

for comboBox i am using

 

<telerik:RadComboBox SelectedIndex="0" x:Name="MembersComboBox"                                    
   ItemsSource="{Binding Members}"
   ItemTemplate="{StaticResource MultiSelectionComboBoxItemTemplate}"
   Visibility="{Binding CanViewOtherUserTrendingConfiguration}"
   SelectionBoxTemplate="{StaticResource MultiSelectionComboBoxSelectionBoxTemplate}"
   ToolTip="{Binding SelectedMembersText}"
   Width="150" Height="20" />
 as i am using MVVM pattern, above comboBox is contained in a user Control RadDocumentPane, and MainChartView userControl DataContext contains the ViewModel

<telerik:RadDocumentPane x:Class="MainChart.MainChartView"
...
>

 and datatemplate MultiSelectionComboBoxSelectionBoxTemplate is defined as

<DataTemplate x:Key="MultiSelectionComboBoxSelectionBoxTemplate">
 <TextBlock Text="{Binding RelativeSource={RelativeSource AncestorType={x:Type telerik:RadDocumentPane}, Mode=FindAncestor}, Path=DataContext.SelectedMembersText}" />
</DataTemplate>

 my question is when i check the checkboxes in the comboBox, it updates the tooltip of combo box, which is bind to viewModel's property SelectedMembersText, but it do not updates the textlbock inside the SelectionBoxTemplate. I am sure i am making some mistake in doing dataBinding. please help me fixing this issue, as i have already applied all possible ways(in my knowledge) of binding textBlock to the field.

 

 

 

 

 

 

 

 

 

1.<telerik:RadComboBox SelectedIndex="0" x:Name="MembersComboBox"                                    
2.                                     ItemsSource="{Binding Members}"
3.                                     ItemTemplate="{StaticResource MultiSelectionComboBoxItemTemplate}"
4.                                  
5.                                     Visibility="{Binding CanViewOtherUserTrendingConfiguration}"
6.                                     SelectionBoxTemplate="{StaticResource MultiSelectionComboBoxSelectionBoxTemplate}"
7.                                     ToolTip="{Binding SelectedMembersText}"
8.                                     Width="150" Height="20" />
1.<telerik:RadComboBox SelectedIndex="0" x:Name="MembersComboBox"                                    
2.                                     ItemsSource="{Binding Members}"
3.                                     ItemTemplate="{StaticResource MultiSelectionComboBoxItemTemplate}"
4.                                  
5.                                     Visibility="{Binding CanViewOtherUserTrendingConfiguration}"
6.                                     SelectionBoxTemplate="{StaticResource MultiSelectionComboBoxSelectionBoxTemplate}"
7.                                     ToolTip="{Binding SelectedMembersText}"
8.                                     Width="150" Height="20" />

2 Answers, 1 is accepted

Sort by
0
Abdul
Top achievements
Rank 1
answered on 03 Aug 2015, 04:17 PM
i am using code from this post
0
Accepted
Kalin
Telerik team
answered on 04 Aug 2015, 06:48 AM
Hi Abdul,

I already replied on the support ticket regarding the same question. I will post my answer here as well:

You can check the output Visual Studio window for any binding errors. However I tested the explained scenario and managed to achieve the desired using the following binding (the ComboBox should inherit the DataContext of the Pane):
Copy Code
<DataTemplate x:Key="MultiSelectionComboBoxSelectionBoxTemplate">
    <TextBlock Text="{Binding RelativeSource={RelativeSource AncestorType={x:Type telerik:RadComboBox}, Mode=FindAncestor},        Path=DataContext.SelectedMembersText}" />
</DataTemplate>

Please test it and let me know if it works for you. If it doesn't work, I would like to ask you to share a sample project reproducing the explained behavior, so we can investigate it on our side.


Hope this helps.


Regards,
Kalin
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
ComboBox
Asked by
Abdul
Top achievements
Rank 1
Answers by
Abdul
Top achievements
Rank 1
Kalin
Telerik team
Share this question
or