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

WPF styles

1 Answer 148 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Rayne
Top achievements
Rank 1
Rayne asked on 02 Dec 2010, 11:28 PM
I'm a newbie with WPF and I copied some code into my Resource Dictionary so that all standard TextBoxes and Buttons would get the radcontrols styles. I found it in another thread.

<Style TargetType="Button" 
         BasedOn="{StaticResource {telerik:ThemeResourceKey ThemeType=telerik:Windows7Theme, ElementType=Button}}" />
  <Style TargetType="ListBox" 
         BasedOn="{StaticResource {telerik:ThemeResourceKey ThemeType=telerik:Windows7Theme, ElementType=ListBox}}" />
<Style TargetType="TextBox" 
         BasedOn="{StaticResource {telerik:ThemeResourceKey ThemeType=telerik:Windows7Theme, ElementType=TextBox}}" />
<Style TargetType="CheckBox" 
         BasedOn="{StaticResource {telerik:ThemeResourceKey ThemeType=telerik:Windows7Theme, ElementType=CheckBox}}" />


Now, I found that I can customize the error template using the following code.

<Style TargetType="Control" x:Key="ValidationErrorTemplate">
    <Style.Triggers>
      <Trigger Property="Validation.HasError" Value="True">
        <Setter Property="ToolTip"
                Value="{Binding RelativeSource={x:Static RelativeSource.Self},
                Path=(Validation.Errors)[0].ErrorContent}" />
      </Trigger>
    </Style.Triggers>
  </Style>
  
<Style TargetType="TextBox" BasedOn={StaticResource ValidationErrorTemplate}" />

How do I combine the two TextBox styles so that I can keep the Error Template at a common level (Control), and use it for all controls. Can I change the Error template style to be based on the Telerik ThemeResourceKey for Control? then base all other controls on it instead?

1 Answer, 1 is accepted

Sort by
0
Accepted
Vanya Pavlova
Telerik team
answered on 06 Dec 2010, 04:56 PM
Hello Rayne,


I have spent some time to investigate your request and I am curious to heard why do you actually need to do that? Each RadControl as part of the Telerik's suite follows its own logic that resides in its template, including its validation logic too. It could be great effort to customize validation tooltip's appearance of each control to achieve this result - common validation look and feel for all controls as part of your application.
  
<Style TargetType="TextBox" BasedOn="{StaticResource {telerik:ThemeResourceKey ThemeType=telerik:Windows7Theme, ElementType=TextBox}}">
  <Style.Triggers
      <Trigger Property="Validation.HasError" Value="True"
        <Setter Property="ToolTip"
                Value="{Binding RelativeSource={x:Static RelativeSource.Self}, 
                Path=(Validation.Errors)[0].ErrorContent}" /> 
      </Trigger
    </Style.Triggers>
</Style>

You may set the markup above within the style in this way.

<Style TargetType="TextBox" BasedOn="{StaticResource {telerik:ThemeResourceKey ThemeType=telerik:Windows7Theme, ElementType=TextBox}}"> .....</>


Regards,
Vanya Pavlova
the Telerik team
Browse the videos here>> to help you get started with RadControls for WPF
Tags
General Discussions
Asked by
Rayne
Top achievements
Rank 1
Answers by
Vanya Pavlova
Telerik team
Share this question
or