MultiSelect ComboBox SelectionBoxTemplate binding issue

3 posts, 1 answers
  1. abdul
    abdul avatar
    7 posts
    Member since:
    Jun 2011

    Posted 02 Aug 2015 Link to this post

    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. abdul
    abdul avatar
    7 posts
    Member since:
    Jun 2011

    Posted 03 Aug 2015 in reply to abdul Link to this post

    i am using code from this post
  3. UI for WPF is Visual Studio 2017 Ready
  4. Answer
    Kalin
    Admin
    Kalin avatar
    1209 posts

    Posted 04 Aug 2015 Link to this post

    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
Back to Top