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

Error Applying Style to RadButton

2 Answers 286 Views
Wizard
This is a migrated thread and some comments may be shown as answers.
Ricardo
Top achievements
Rank 1
Ricardo asked on 28 May 2018, 01:33 PM

Hello,

 

I'm developing an installation wizard, and i have a resource for radbuttons.

 

Everything seems ok upon creation, but when i put the mouse over the button or i press it i get the following error:

 

System.Windows.Data Error: 40 : BindingExpression path error: '(MaterialControls:MaterialAssist.MouseOverBrush)' property not found on 'object' ''RadButton' (Name='LoginButton')'. BindingExpression:Path=(MaterialControls:MaterialAssist.MouseOverBrush); DataItem='RadButton' (Name='LoginButton'); target element is 'Border' (Name='BorderVisual'); target property is 'Background' (type 'Brush')

 

I have no idea what is wrong.

 

Code for button in wizard:

<telerik:RadButton x:Name="LoginButton"
                                       Margin="0 180 0 35"
                                       HorizontalAlignment="Center" 
                                       Content="Submit"                     
                                       Height="40" Width="105"                               
                                       VerticalAlignment="Bottom"
                                       Click="LoginButton_Click"
                                       MouseEnter="LoginButton_MouseEnter"
                                       MouseLeave="LoginButton_MouseLeave"
                                       Style="{DynamicResource TestButton}"
                                       CommandParameter="{Binding}"/>

 

code

<Style x:Key="TestButton" TargetType="{x:Type telerik:RadButton}">
        <Setter Property="MinWidth" Value="70"/>
        <Setter Property="Margin" Value="0,0,5,0"/>
        <Setter Property="HorizontalAlignment" Value="Left"/>
        <Setter Property="VerticalAlignment" Value="Center"/>
        <Style.BasedOn>
            <Style TargetType="{x:Type telerik:RadButton}">
                <Setter Property="MaterialControls:MaterialAssist.MouseOverBrush" Value="{telerik:FluentResource ResourceKey={x:Static telerik:FluentResourceKey.MouseOverBrush}}"/>
                <Setter Property="MaterialControls:MaterialAssist.PressedBrush" Value="{telerik:FluentResource ResourceKey={x:Static telerik:FluentResourceKey.PressedBrush}}"/>
                <Setter Property="MaterialControls:MaterialAssist.FocusBrush" Value="{telerik:FluentResource ResourceKey={x:Static telerik:FluentResourceKey.AccentFocusedBrush}}"/>
                <Setter Property="FontFamily" Value="{telerik:FluentResource ResourceKey={x:Static telerik:FluentResourceKey.FontFamily}}"/>
                <Setter Property="FontSize" Value="{telerik:FluentResource ResourceKey={x:Static telerik:FluentResourceKey.FontSize}}"/>
                <Setter Property="Foreground" Value="{telerik:FluentResource ResourceKey={x:Static telerik:FluentResourceKey.MarkerBrush}}"/>
                <Setter Property="Background" Value="{telerik:FluentResource ResourceKey={x:Static telerik:FluentResourceKey.MainBrush}}"/>
                <Setter Property="BorderBrush" Value="{telerik:FluentResource ResourceKey={x:Static telerik:FluentResourceKey.MainBrush}}"/>
                <Setter Property="BorderThickness" Value="1"/>
                <Setter Property="Padding" Value="5"/>
                <Setter Property="CornerRadius" Value="{telerik:FluentResource ResourceKey={x:Static telerik:FluentResourceKey.CornerRadius}}"/>
                <Setter Property="SnapsToDevicePixels" Value="True"/>
                <Setter Property="UseLayoutRounding" Value="True"/>
                <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
                <Setter Property="HorizontalContentAlignment" Value="Center"/>
                <Setter Property="VerticalContentAlignment" Value="Center"/>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type telerik:RadButton}">
                            <Grid>
                                <Border x:Name="BorderVisual" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" CornerRadius="{TemplateBinding CornerRadius}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                                <Border x:Name="FocusVisual" BorderBrush="{TemplateBinding MaterialControls:MaterialAssist.FocusBrush}" BorderThickness="{DynamicResource {x:Static telerik:FluentResourceKey.FocusThickness}}" CornerRadius="{TemplateBinding CornerRadius}" IsHitTestVisible="False" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Visibility="Collapsed"/>
                                <MaterialControls:FluentControl BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="{TemplateBinding CornerRadius}" HorizontalContentAlignment="Stretch" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalContentAlignment="Stretch">
                                    <ContentPresenter x:Name="Content" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" ContentStringFormat="{TemplateBinding ContentStringFormat}" TextElement.Foreground="{TemplateBinding Foreground}" Focusable="False" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                                </MaterialControls:FluentControl>
                            </Grid>
                            <ControlTemplate.Triggers>
                                <MultiTrigger>
                                    <MultiTrigger.Conditions>
                                        <Condition Property="IsBackgroundVisible" Value="False"/>
                                        <Condition Property="IsEnabled" Value="True"/>
                                        <Condition Property="IsMouseOver" Value="False"/>
                                    </MultiTrigger.Conditions>
                                    <Setter Property="Background" Value="Transparent"/>
                                    <Setter Property="BorderBrush" Value="Transparent"/>
                                </MultiTrigger>
                                <MultiTrigger>
                                    <MultiTrigger.Conditions>
                                        <Condition Property="IsEnabled" Value="True"/>
                                        <Condition Property="IsFocused" Value="True"/>
                                        <Condition Property="IsPressed" Value="False"/>
                                        <Condition Property="IsMouseOver" Value="False"/>
                                    </MultiTrigger.Conditions>
                                    <Setter Property="Visibility" TargetName="FocusVisual" Value="Visible"/>
                                </MultiTrigger>
                                <Trigger Property="IsMouseOver" Value="True">
                                    <Setter Property="Background" TargetName="BorderVisual" Value="{Binding (MaterialControls:MaterialAssist.MouseOverBrush), Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}"/>
                                    <Setter Property="BorderBrush" TargetName="BorderVisual" Value="{Binding (MaterialControls:MaterialAssist.MouseOverBrush), Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}"/>
                                </Trigger>
                                <Trigger Property="IsPressed" Value="True">
                                    <Setter Property="Background" TargetName="BorderVisual" Value="{Binding (MaterialControls:MaterialAssist.PressedBrush), Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}"/>
                                    <Setter Property="BorderBrush" TargetName="BorderVisual" Value="{Binding (MaterialControls:MaterialAssist.PressedBrush), Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}"/>
                                </Trigger>
                                <Trigger Property="IsEnabled" Value="False">
                                    <Setter Property="Opacity" TargetName="Content" Value="{telerik:FluentResource ResourceKey={x:Static telerik:FluentResourceKey.DisabledOpacity}}"/>
                                    <Setter Property="Background" Value="{telerik:FluentResource ResourceKey={x:Static telerik:FluentResourceKey.AlternativeBrush}}"/>
                                    <Setter Property="BorderBrush" Value="{telerik:FluentResource ResourceKey={x:Static telerik:FluentResourceKey.AlternativeBrush}}"/>
                                </Trigger>
                                <MultiTrigger>
                                    <MultiTrigger.Conditions>
                                        <Condition Property="IsEnabled" Value="False"/>
                                        <Condition Property="IsFocused" Value="True"/>
                                    </MultiTrigger.Conditions>
                                    <Setter Property="Visibility" TargetName="FocusVisual" Value="Collapsed"/>
                                </MultiTrigger>
                                <MultiTrigger>
                                    <MultiTrigger.Conditions>
                                        <Condition Property="IsEnabled" Value="False"/>
                                        <Condition Property="IsBackgroundVisible" Value="False"/>
                                    </MultiTrigger.Conditions>
                                    <Setter Property="Background" Value="Transparent"/>
                                    <Setter Property="BorderBrush" Value="Transparent"/>
                                </MultiTrigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
        </Style.BasedOn>
    </Style>

Can someone please help me?

 

Regards

 

2 Answers, 1 is accepted

Sort by
0
Vladimir Stoyanov
Telerik team
answered on 31 May 2018, 08:38 AM
Hello Ricardo,

Thank you for the provided xaml.

I tested this on my side but I was not able to reproduce the error. I am attaching the sample project that I used. May I ask you to check it out and share what you are doing differently on your side? If possible, you can also modify the attached project in order to reproduce the described scenario and attach it to a new support ticket. This way I will be able to further investigate.

I am looking forward to your reply.

Regards,
Vladimir Stoyanov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Ricardo
Top achievements
Rank 1
answered on 06 Jun 2018, 02:19 PM

Hi Vladimir,

 

I was trying to use an external resource dictionary where i placed all the styles and then call it from App.xml.

It appears that this doesn't work very well, i copied all the styles into MainWindow.xml and the app started working normally.

 

Thanks for the help

Tags
Wizard
Asked by
Ricardo
Top achievements
Rank 1
Answers by
Vladimir Stoyanov
Telerik team
Ricardo
Top achievements
Rank 1
Share this question
or