IsFocused Background Trigger

4 posts, 1 answers
  1. Daniel Schuessler
    Daniel Schuessler avatar
    7 posts
    Member since:
    Mar 2010

    Posted 30 Mar 2010 Link to this post

    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> 
      
  2. Answer
    Hristo
    Admin
    Hristo avatar
    832 posts

    Posted 02 Apr 2010 Link to this post

    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.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Rakhi
    Rakhi avatar
    10 posts
    Member since:
    Aug 2010

    Posted 20 Oct 2010 Link to this post

    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
  5. Dani
    Admin
    Dani avatar
    848 posts

    Posted 25 Oct 2010 Link to this post

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