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

IsFocused Background Trigger

3 Answers 444 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Daniel Schuessler
Top achievements
Rank 1
Daniel Schuessler asked on 30 Mar 2010, 10:15 PM
In the RadComboBox I have a IsMouseOver trigger and an IsFocused trigger.  The IsMouseOver trigger changes the background color while the IsFocused trigger does not.  How can I make this work?  I've also tried doing this in the editabletemplate with no luck.

Here is test markup that demonstrates:  It should trigger a Black background on keyboard focus.

<Window 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" 
    x:Class="WpfApplication12.MainWindow" 
    x:Name="Window" 
    Title="MainWindow" 
    Width="327" Height="217"
 
<Window.Resources> 
 <Style  x:Key="{x:Type telerik:RadComboBox}"  TargetType="{x:Type telerik:RadComboBox}"
     <Style.Triggers> 
        <MultiTrigger> 
          <MultiTrigger.Conditions> 
             <Condition Property="IsEnabled" Value="True"/> 
             <Condition Property="IsFocused" Value="True"/> 
          </MultiTrigger.Conditions>                             
          <Setter Property="Background" Value="Black" /> 
        </MultiTrigger> 
        <MultiTrigger> 
          <MultiTrigger.Conditions> 
             <Condition Property="IsEnabled" Value="True"/> 
             <Condition Property="IsMouseOver" Value="True"/> 
          </MultiTrigger.Conditions>                             
          <Setter Property="Background" Value="Blue" /> 
        </MultiTrigger> 
     </Style.Triggers> 
 </Style> 
  
</Window.Resources> 
 
    <Grid x:Name="LayoutRoot"
        <Grid.RowDefinitions> 
         <RowDefinition Height="50" /> 
         <RowDefinition Height="50" /> 
        </Grid.RowDefinitions> 
        <TextBox >Some text</TextBox> 
        <telerik:RadComboBox  Grid.Row="1" IsEditable="True" IsReadOnly="True" Margin="0,0,0,1"
            <telerik:RadComboBoxItem Content="Item 1"/> 
            <telerik:RadComboBoxItem Content="Item 2"/> 
            <telerik:RadComboBoxItem Content="Item 3"/> 
        </telerik:RadComboBox> 
    </Grid> 
</Window> 
  

3 Answers, 1 is accepted

Sort by
1
Accepted
Hristo
Telerik team
answered on 02 Apr 2010, 10:10 AM
Hello Daniel Schuessler,

You should use IsKeyboardFocusWithin instead of IsFocused.

Let us know if this helps you.

Regards,
Hristo
the Telerik team

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 Public Issue Tracking system and vote to affect the priority of the items.
0
Rakhi
Top achievements
Rank 1
answered on 20 Oct 2010, 08:17 AM
I want to set visibility of another UI control id radcombox selectedindex=0.
I used this code but this is not working please tell me how can i do this ?

<telerikInput:RadComboBox x:Name="cmbGaugeType" SelectedIndex="0" SelectedValue="{Binding Path=GaugeType}"
                                                          ItemsSource="{Binding Source={StaticResource gaugeType}}" Width="72">
<telerikInput:RadComboBox.Triggers>
         <Trigger Property="SelectedIndex" Value="0">
                 <Setter TargetName="pnlRadialType" Property="Visibility" Value="Visible"/>
                </Trigger>
</telerikInput:RadComboBox.Triggers>
</telerikInput:RadComboBox>


Thanks
0
Dani
Telerik team
answered on 25 Oct 2010, 06:07 AM
Hi Rakhi,

The posted code snippet does not work because there is no such state as SelectedIndex.
I suggest you would better bind the Visibility property of the element you need to show/hide to the SelectedIndex property of the ComboBox. Additionaly you would need to use a converter to match the property values.

For example:
<Border x:Name="HideThis" Visibility={Binding Path=SelectedIndex, ElementName=cmbGaugeType, Converter={StaticResource IntToBoolConverter}} />


Sincerely yours,
Dani
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
Tags
ComboBox
Asked by
Daniel Schuessler
Top achievements
Rank 1
Answers by
Hristo
Telerik team
Rakhi
Top achievements
Rank 1
Dani
Telerik team
Share this question
or