Custom tool tip

10 posts, 1 answers
  1. Kristjan Einarsson
    Kristjan Einarsson avatar
    95 posts
    Member since:
    Jan 2010

    Posted 13 Sep 2011 Link to this post

    Hi,
    I is there a way to have custom tool tips for each comboboxitem in the combobox ?

    <telerik:RadComboBox Name="comboWorkingPlan" Height="20" Width="100"
    DisplayMemberPath="Name"
    SelectionChanged="comboWorkingPlan_SelectionChanged"
    SelectedItem="{Binding Source={StaticResource MainUIDataSource}, Path=Class, Mode=TwoWay}"
    ItemsSource="{Binding Source={StaticResource MainUIDataSource}, Path=PlansDataSource.AllClasses}" Initialized="comboWorkingPlan_Initialized"/>

    Lets say I have a property called "Description" for each Class, would I be able to display that as a tooltip ?

    Cheers
    Kristján
  2. Answer
    Pana
    Admin
    Pana avatar
    748 posts

    Posted 16 Sep 2011 Link to this post

    Hi,

    It is possible using ItemContainerStyle and applying ToolTip in a Setter there bound to a property of your view model. Please refer to the attached project.

    Greetings,
    Pana
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
  3. UI for WPF is Visual Studio 2017 Ready
  4. Kristjan Einarsson
    Kristjan Einarsson avatar
    95 posts
    Member since:
    Jan 2010

    Posted 16 Sep 2011 Link to this post

    Thank you :)
  5. Siva Prakash
    Siva Prakash avatar
    14 posts
    Member since:
    Sep 2011

    Posted 23 Dec 2011 Link to this post

    Hi,

    In my project, I am facing one problem with the tooltip of the radcomboBox. It's like this -->

    I want to show a tooltip which displays the ID of the item when focus is placed on the combobox item.
    And also I am able to achieve this one perfectly. But what the problem I am facing now is -  The ComboBox items are not getting displayed in the container. Please help me out in resolving this.

    Regards
    K Siva Prakash.
  6. Siva Prakash
    Siva Prakash avatar
    14 posts
    Member since:
    Sep 2011

    Posted 23 Dec 2011 Link to this post

    This is my code snippet.

    <
    telerik:RadComboBox HorizontalAlignment="Center" 
                                              VerticalAlignment="Center"  
                                              Width="283" 
                                              ItemsSource="{Binding Items}"
                                              DisplayMemberPath="Name" 
                                              SelectedValuePath="Id" 
                                              SelectedValue="{Binding Path=SelectedItem, Mode=TwoWay}" 
                                              Margin="100,100">
                <telerik:RadComboBox.ItemContainerStyle>
                    <Style TargetType="telerik:RadComboBoxItem">
                        <Setter Property="Content" Value="{Binding Name}"/>
                        <Setter Property="ToolTip" Value="{Binding Id}"/>
                    </Style>
                </telerik:RadComboBox.ItemContainerStyle>
            </telerik:RadComboBox>
  7. Dani
    Admin
    Dani avatar
    848 posts

    Posted 23 Dec 2011 Link to this post

    Hi Siva Prakash,

    Please try the following XAML snippet instead. I believe you have a wrong Binding and a missing SelectionBoxTemplate.

    <Window.Resources>
            <DataTemplate x:Key="SelectionBoxTemplate">
                <TextBlock Text="{Binding Id}" />
            </DataTemplate>
        </Window.Resources>
        <Grid>
            <telerik:RadComboBox HorizontalAlignment="Center" 
                                 VerticalAlignment="Center"  
                                 Width="283"
                                 ItemsSource="{Binding}" 
                                 SelectionBoxTemplate="{StaticResource SelectionBoxTemplate}"
                                 Margin="100,100">          
                <telerik:RadComboBox.ItemContainerStyle>
                    <Style TargetType="telerik:RadComboBoxItem">
                        <Setter Property="Content" Value="{Binding Name}"/>
                        <Setter Property="ToolTip" Value="{Binding Id}"/>
                    </Style>
                </telerik:RadComboBox.ItemContainerStyle>           
            </telerik:RadComboBox>
        </Grid>

    I hope this will help solve your issue.

    Kind regards,
    Dani
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
  8. Siva Prakash
    Siva Prakash avatar
    14 posts
    Member since:
    Sep 2011

    Posted 23 Dec 2011 Link to this post

    Hi,
  9. Siva Prakash
    Siva Prakash avatar
    14 posts
    Member since:
    Sep 2011

    Posted 23 Dec 2011 Link to this post

    Hi,

    Actually I am able to show the seleted value in the comboBox. It's not the problem what I am facing. Please see the attached image.
    I am not able to see the items in the Collection container of RadComboBox. Here Binding of the selectedValue is must for me. I can't remove that one from the xaml.
    Please look at this and provide me a solution. I tried to send a sample code. But I am not knowing how to send. Tell me how to send a sample code. If you require, then I will send it.


    Thanks & Regards
    K Siva Prakash.
  10. Dani
    Admin
    Dani avatar
    848 posts

    Posted 27 Dec 2011 Link to this post

    Hi Siva,

    Please, use either the DisplayMemberPath property or the Content property setter in the ItemContainerStyle. Using both results in your items not being shown.

    Try the following:
    <telerik:RadComboBox HorizontalAlignment="Center" 
                                              VerticalAlignment="Center"  
                                              Width="283" 
                                              ItemsSource="{Binding}"   
                                              DisplayMemberPath="Name"
                                              SelectedValuePath="Id" 
                                              SelectedValue="{Binding Path=SelectedItem, Mode=TwoWay}" 
                                              Margin="100,100">
                <telerik:RadComboBox.ItemContainerStyle>
                    <Style TargetType="telerik:RadComboBoxItem">                    
                        <Setter Property="ToolTip" Value="{Binding Id}"/>
                    </Style>
                </telerik:RadComboBox.ItemContainerStyle>
            </telerik:RadComboBox>

    I hope this will be helpful.

    Kind regards,
    Dani
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
  11. Siva Prakash
    Siva Prakash avatar
    14 posts
    Member since:
    Sep 2011

    Posted 27 Dec 2011 Link to this post

    Hi Dani,

    The previous solution resolved my issue. Thanks for that.

    Regards
    K Siva Prakash.
Back to Top
UI for WPF is Visual Studio 2017 Ready