RadButton: DataTrigger in Style

3 posts, 0 answers
  1. Helmut
    Helmut avatar
    3 posts
    Member since:
    Jan 2013

    Posted 30 Jul 2013 Link to this post

    I got the following simplified XAML-Snippet:

    <telerik:RadToolBar Grid.Row="0">
          <Style TargetType="telerik:RadButton">
              <DataTrigger Binding="{Binding Type}"
                           Value="{x:Static data:ReceiverGroupType.Fix}">
                <Setter Property="Visibility"
      </telerik:RadButton.Content> </telerik:RadButton>
    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.
  2. Helmut
    Helmut avatar
    3 posts
    Member since:
    Jan 2013

    Posted 30 Jul 2013 Link to this post


    A quick test, where I moved the Button outside the ToolBar makes the DataTrigger to work.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Pavel R. Pavlov
    Pavel R. Pavlov avatar
    1182 posts

    Posted 02 Aug 2013 Link to this post

    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.

    Pavel R. Pavlov
    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 >>
Back to Top