Click here to Skip to main content
15,884,388 members
Home / Discussions / WPF
   

WPF

 
AnswerRe: Displaying a grid of mixed controls from tabular data Pin
Pete O'Hanlon7-Jun-18 4:06
mvePete O'Hanlon7-Jun-18 4:06 
AnswerRe: Displaying a grid of mixed controls from tabular data Pin
Gerry Schmitz7-Jun-18 7:01
mveGerry Schmitz7-Jun-18 7:01 
GeneralRe: Displaying a grid of mixed controls from tabular data Pin
Leif Simon Goodwin14-Jun-18 21:36
Leif Simon Goodwin14-Jun-18 21:36 
QuestionWPF Toolkit PropertyGrid Pin
Kevin Marois5-Jun-18 4:30
professionalKevin Marois5-Jun-18 4:30 
SuggestionRe: WPF Toolkit PropertyGrid Pin
Richard Deeming5-Jun-18 9:30
mveRichard Deeming5-Jun-18 9:30 
GeneralRe: WPF Toolkit PropertyGrid Pin
Kevin Marois5-Jun-18 10:24
professionalKevin Marois5-Jun-18 10:24 
GeneralRe: WPF Toolkit PropertyGrid Pin
Richard Deeming6-Jun-18 1:21
mveRichard Deeming6-Jun-18 1:21 
QuestionStyle Problem Pin
Kevin Marois9-May-18 12:03
professionalKevin Marois9-May-18 12:03 
I created an Image button called MultiImageButton with 4 properties for Normal, Mouse Over, Disabled, and Pressed. I won't post the class code (unless you want me to ) because it works and isn't the problem. The class is in the Controls folder.

In the same project I created a style for it:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
                    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
                    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
                    xmlns:System="clr-namespace:System;assembly=mscorlib" 
                    xmlns:sys="clr-namespace:System;assembly=mscorlib"
                    xmlns:cctrls="clr-namespace:Controls"
                    mc:Ignorable="d">

<pre>
<!THE TEMPLATE>
<ControlTemplate x:Key="MultiImageButtonTemplate" 
                 TargetType="{x:Type cctrls:MultiImageButton}">

    <Grid x:Name="Grid">

        <Border  x:Name="Background" 
                 Background="{TemplateBinding Background}" 
                 BorderBrush="{TemplateBinding BorderBrush}" 
                 BorderThickness="{TemplateBinding BorderThickness}" 
                 CornerRadius="0" 
                 Visibility="{Binding BorderVisibility, RelativeSource={RelativeSource TemplatedParent}}"/>

        <StackPanel Orientation="Horizontal" 
                    VerticalAlignment="{TemplateBinding VerticalContentAlignment}" 
                    HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}">

            <Image x:Name="ButtonImage" 
                   Source="{Binding NormalImage, RelativeSource={RelativeSource TemplatedParent}}" 
                   Height="{Binding ImageSize, RelativeSource={RelativeSource TemplatedParent}}" 
                   Width="{Binding ImageSize, RelativeSource={RelativeSource TemplatedParent}}"
                   ToolTip="{TemplateBinding ToolTip}"/>

            <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
                              Margin="{TemplateBinding Padding}" 
                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}" 
                              RecognizesAccessKey="True" />
        </StackPanel>

    </Grid>

    <ControlTemplate.Triggers>
        <Trigger Property="IsMouseOver" Value="true">
            <Setter TargetName="ButtonImage" Property="Source" Value="{Binding HoverImage, RelativeSource={RelativeSource TemplatedParent}}" />
        </Trigger>
        <Trigger Property="IsPressed" Value="true">
            <Setter TargetName="ButtonImage" Property="Source" Value="{Binding PressedImage, RelativeSource={RelativeSource TemplatedParent}}" />
        </Trigger>
        <Trigger Property="IsEnabled" Value="false">
            <Setter TargetName="ButtonImage" Property="Source" Value="{Binding DisabledImage, RelativeSource={RelativeSource TemplatedParent}}" />
        </Trigger>
    </ControlTemplate.Triggers>

</ControlTemplate>

<!IMAGE BUTTON BASE STYLE>
<Style x:Key="MultiImageButtonStyle" 
       TargetType="{x:Type cctrls:MultiImageButton}" 
       BasedOn="{StaticResource {x:Type cctrls:MultiImageButton}}">

    <Setter Property="Cursor" Value="Hand"/>
    <Setter Property="Template" Value="{StaticResource MultiImageButtonTemplate}" />

</Style>

<!NAV LEFT BUTTON STYLE>
<Style x:Key="NavLeftButtonStyleStyle" 
       TargetType="{x:Type cctrls:MultiImageButton}" 
       BasedOn="{StaticResource MultiImageButtonStyle}">

    <Setter Property="ImageSize" Value="32"/>

    <Setter Property="NormalImage"      Value="/GenMarkDX.RemoteManagement.Common;component/Media/Images/arrow_left_normal.png"/>
    <Setter Property="HoverImage"       Value="/GenMarkDX.RemoteManagement.Common;component/Media/Images/arrow_left_mouseover.png"/>
    <Setter Property="PressedImage"     Value="/GenMarkDX.RemoteManagement.Common;component/Media/Images/arrow_left_normal.png"/>
    <Setter Property="DisabledImage"    Value="/GenMarkDX.RemoteManagement.Common;component/Media/Images/arrow_left_disabled.png"/>

</Style>




In a different project I added it to a window:
xmlns:cctrls="clr-namespace:Common.Controls;assembly=Common"
.
.
.
<cctrls:MultiImageButton Grid.Row="1"
                            Grid.Column="0"
                            Command="{Binding NavLeftCommand}"
                            Margin="5"
                            Style="{StaticResource NavLeftButtonStyleStyle}"/>
When I run this I get the error: "Cannot find resource named 'Common.Controls.MultiImageButton'. Resource names are case sensitive."

Again, the class with the button is in the same project as the style. There's no reason that I can see why the style shouldn't find the class. This works in a different app, just not here.

Anyone see what's wrong?
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.

AnswerRe: Style Problem Pin
Mycroft Holmes9-May-18 14:25
professionalMycroft Holmes9-May-18 14:25 
QuestionDataGrid Template Column Binding Pin
Kevin Marois9-May-18 5:05
professionalKevin Marois9-May-18 5:05 
AnswerRe: DataGrid Template Column Binding Pin
Nathan Minier9-May-18 7:15
professionalNathan Minier9-May-18 7:15 
GeneralRe: DataGrid Template Column Binding Pin
Kevin Marois9-May-18 9:48
professionalKevin Marois9-May-18 9:48 
GeneralRe: DataGrid Template Column Binding Pin
Nathan Minier10-May-18 1:04
professionalNathan Minier10-May-18 1:04 
QuestionDataGrid DataGridCheckBoxColumn Property Change Not Firing Pin
Kevin Marois2-May-18 6:52
professionalKevin Marois2-May-18 6:52 
AnswerRe: DataGrid DataGridCheckBoxColumn Property Change Not Firing Pin
Richard Deeming2-May-18 8:40
mveRichard Deeming2-May-18 8:40 
GeneralRe: DataGrid DataGridCheckBoxColumn Property Change Not Firing Pin
Kevin Marois2-May-18 9:46
professionalKevin Marois2-May-18 9:46 
QuestionWPF NIC counters Pin
Member 138058691-May-18 13:33
Member 138058691-May-18 13:33 
AnswerRe: WPF NIC counters Pin
Gerry Schmitz2-May-18 11:27
mveGerry Schmitz2-May-18 11:27 
QuestionMagnify shader effect Pin
Nick Hallas1-May-18 10:33
Nick Hallas1-May-18 10:33 
AnswerRe: Magnify shader effect Pin
Gerry Schmitz2-May-18 11:39
mveGerry Schmitz2-May-18 11:39 
QuestionAssign Collection Items In XAML Pin
Kevin Marois23-Apr-18 8:40
professionalKevin Marois23-Apr-18 8:40 
AnswerRe: Assign Collection Items In XAML Pin
Richard Deeming23-Apr-18 8:58
mveRichard Deeming23-Apr-18 8:58 
GeneralRe: Assign Collection Items In XAML Pin
Kevin Marois23-Apr-18 9:25
professionalKevin Marois23-Apr-18 9:25 
AnswerRe: Assign Collection Items In XAML Pin
Maciej Los23-Apr-18 9:56
mveMaciej Los23-Apr-18 9:56 
GeneralRe: Assign Collection Items In XAML Pin
Kevin Marois23-Apr-18 10:00
professionalKevin Marois23-Apr-18 10:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.