0

I have to add a RadComboBox inside a GridViewDataColumn. This combo box has to be populated with a List. I have to make a condition that if the List is empty then this combo box should be disabled and a tooltip message has to be shown that "No Settings available".

Below is my code in xaml file:

<telerikGrid:GridViewDataColumn HeaderCellStyle="{StaticResource HeaderStyle}"
                                                            Width="Auto"
                                                            Header="Decrypt" x:Name="colDecrypt">
    <telerikGrid:GridViewColumn.CellStyle>
        <Style TargetType="telerikGridView:GridViewCell">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="telerikGridView:GridViewCell">
                        <Border>
                            <telerik:RadComboBox x:Name="cbxDecrypt" Margin="5,1,5,1" Width="Auto"
                                            ItemsSource="{Binding Mode=OneWay, Source={StaticResource Parameter}, Path=EquivalenceNames}"
                                            SelectionChanged="cbxDecrypt_SelectionChanged" SelectedItem="{Binding SelectedEquivalence}"
                                            ToolTipService.ToolTip="No Decrypt Settings available"
                                            />
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </telerikGrid:GridViewColumn.CellStyle>
</telerikGrid:GridViewDataColumn>

Any help will be really appreciated.

Spawn
  • 935
  • 1
  • 13
  • 32
Shivam Gupta
  • 429
  • 4
  • 16

2 Answers2

0

I have create a simple example: we will use ObservableCollection as DataContext:

DataContext = new ObservableCollection<string>();

By default tooltip doesn't showing on Disabled controls, so we need to use ToolTipService.ShowOnDisabled property.

<telerik:RadComboBox ToolTipService.ShowOnDisabled="True" ItemsSource="{Binding}">
    <telerik:RadComboBox.Style>
        <Style TargetType="telerik:RadComboBox">
            <Style.Triggers>
                <DataTrigger Binding="{Binding Count, Mode=OneWay}" Value="0">
                    <Setter Property="IsEnabled" Value="False"/>
                    <Setter Property="ToolTip" Value="No Decrypt Settings available"/>
                </DataTrigger>    
            </Style.Triggers>
        </Style>
    </telerik:RadComboBox.Style>
</telerik:RadComboBox>

If you use Noxaml version of telerik libraries, then you need some fix like:

<Style TargetType="telerik:RadComboBox" BasedOn="{StaticResource RadComboBoxStyle}">
    <!--...-->
</Style>
Spawn
  • 935
  • 1
  • 13
  • 32
  • I am using it in my Silver light application. When I am using ToolTipService.ShowOnDisabled or Style.Triggers, it is giving an error that "The attachable property 'ShowOnDisabled' was not found in the Type ToolTipService". Is there any specific reason for that? Sorry but I am new to it. – Shivam Gupta Dec 01 '15 at 06:37
  • Yes, in Silverlight we can't use such property. But we have solution - http://www.codeproject.com/Tips/123961/ToolTip-for-Disabled-Element-in-Silverlight – Spawn Dec 01 '15 at 06:41
  • Yes, it works. Can you please suggest how can I disable an item if its source is empty? – Shivam Gupta Dec 01 '15 at 06:47
  • Empty content of source? Some DataTrigger with apropriate condition. – Spawn Dec 01 '15 at 06:52
  • Yes, but Data Trigger also is not supported by Silver light application. Anyways thank you so much for your help :) – Shivam Gupta Dec 01 '15 at 06:54
  • For replacement of DataTrigger you can read here - http://stackoverflow.com/q/3529508/1979354 – Spawn Dec 01 '15 at 07:11
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/96643/discussion-between-spawn-and-shivam-gupta). – Spawn Dec 01 '15 at 07:56
0

I found below links very useful which gives an easy solution to my problem:

  1. For first issue to disable an item if List is empty, a very easy solution is provided here:

ComboBox IsEnabled Binding Question in Silverlight Xaml

  1. For second issue to show a tooltip message, a very good solution is provided here: http://dotplusnet.blogspot.in/2010/09/workaround-for-showing-tooltip-for.html

Using Border Background="Transparent" works like a charm to resolve this issue.

Community
  • 1
  • 1
Shivam Gupta
  • 429
  • 4
  • 16