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

RadButton: DataTrigger in Style

3 Answers 587 Views
Buttons
This is a migrated thread and some comments may be shown as answers.
Helmut
Top achievements
Rank 1
Helmut asked on 30 Jul 2013, 01:32 PM
I got the following simplified XAML-Snippet:

<telerik:RadToolBar Grid.Row="0">
  <telerik:RadButton>
    <telerik:RadButton.Style>
      <Style TargetType="telerik:RadButton">
        <Style.Triggers>
          <DataTrigger Binding="{Binding Type}"
                       Value="{x:Static data:ReceiverGroupType.Fix}">
            <Setter Property="Visibility"
                    Value="Collapsed"/>
          </DataTrigger>
        </Style.Triggers>
      </Style>
    </telerik:RadButton.Style>
    <telerik:RadButton.Content>
...
  </telerik:RadButton.Content> </telerik:RadButton>
</telerik:RadToolBar>
<
telerik:RadGridView Grid.Row="1"              ...> <telerik:RadGridView.Columns>   ...   </telerik:RadGridView.Columns>   <telerik:RadGridView.Style>   <Style TargetType="telerik:RadGridView">     <Style.Triggers>       <DataTrigger Binding="{Binding Type}"                      Value="{x:Static data:ReceiverGroupType.Fix}">         <Setter Property="Visibility"                   Value="Collapsed"/>         </DataTrigger>       </Style.Triggers>     </Style>   </telerik:RadGridView.Style> </telerik:RadGridView>
The DataTrigger for the GridView works, while the DataTrigger for the Button does not: No matter, what the bound Type property's value is, the button stays visible.

3 Answers, 1 is accepted

Sort by
0
Helmut
Top achievements
Rank 1
answered on 30 Jul 2013, 01:57 PM
Self-Reply:

A quick test, where I moved the Button outside the ToolBar makes the DataTrigger to work.
0
Pavel R. Pavlov
Telerik team
answered on 02 Aug 2013, 10:32 AM
Hello Helmut,

You are right that moving the RadButton out of the RadToolBar will work. Let me clarify why this behavior is expected.

Our RadToolBar control reapplies the style of all buttons that are placed inside it (read more). And this is why the changes made from the DataTrigger are overridden by the internal defined Style of the RadToolBar control. This is why if you need to customize the look of a button which is placed inside the toolbar you need to customize the Template of the RadToolBar control. You can find more information about extracting Templates in this article.

Please give this approach a try and let me know if you need further assistance.

Regards,
Pavel R. Pavlov
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
gaurav
Top achievements
Rank 1
answered on 13 May 2019, 08:22 AM

Hello How to change the content(text) and background color of the button on click in wpf radbutton.

Example like in javascript when click on button, it's color and context we can change according to style. how to do in telerik.

 

TIA

Tags
Buttons
Asked by
Helmut
Top achievements
Rank 1
Answers by
Helmut
Top achievements
Rank 1
Pavel R. Pavlov
Telerik team
gaurav
Top achievements
Rank 1
Share this question
or