Click here to Skip to main content
15,886,026 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: Custom Navigation Control Pin
Kevin Marois25-Apr-23 19:02
professionalKevin Marois25-Apr-23 19:02 
GeneralRe: Custom Navigation Control Pin
Kevin Marois27-Apr-23 7:21
professionalKevin Marois27-Apr-23 7:21 
QuestionPath in Style Question Pin
Kevin Marois10-Apr-23 13:43
professionalKevin Marois10-Apr-23 13:43 
AnswerRe: Path in Style Question Pin
Gerry Schmitz12-Apr-23 6:18
mveGerry Schmitz12-Apr-23 6:18 
GeneralRe: Path in Style Question Pin
Kevin Marois12-Apr-23 6:33
professionalKevin Marois12-Apr-23 6:33 
GeneralRe: Path in Style Question Pin
Gerry Schmitz12-Apr-23 7:01
mveGerry Schmitz12-Apr-23 7:01 
GeneralRe: Path in Style Question Pin
Kevin Marois12-Apr-23 7:06
professionalKevin Marois12-Apr-23 7:06 
GeneralRe: Path in Style Question Pin
Kevin Marois18-Apr-23 14:45
professionalKevin Marois18-Apr-23 14:45 
FYI, here's what I came up with. Thanks for your help!

Control
public class MaroisPathImageButton : Button
{
    #region CTOR
    static MaroisPathImageButton()
    {
        DefaultStyleKeyProperty.OverrideMetadata(typeof(MaroisPathImageButton), new FrameworkPropertyMetadata(typeof(MaroisPathImageButton)));
    }
    #endregion

    #region Dependency Properties
    #region DP Caption
    public static readonly DependencyProperty CaptionProperty =
                DependencyProperty.Register("Caption",
                typeof(string),
                typeof(MaroisPathImageButton),
                new PropertyMetadata(""));

    public string Caption
    {
        get { return (string)GetValue(CaptionProperty); }
        set { SetValue(CaptionProperty, value); }
    }
    #endregion

    #region DP PathData
    public static readonly DependencyProperty PathDataProperty =
                DependencyProperty.Register("PathData",
                typeof(System.Windows.Media.Geometry),
                typeof(MaroisPathImageButton),
                new PropertyMetadata(null, new PropertyChangedCallback(OnPathDataChanged)));

    public System.Windows.Media.Geometry PathData
    {
        get { return (System.Windows.Media.Geometry)GetValue(PathDataProperty); }
        set { SetValue(PathDataProperty, value); }
    }

    private static void OnPathDataChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
    {
        MaroisPathImageButton control = (MaroisPathImageButton)d;
    }
    #endregion

    #endregion
}
Theme
<!--PATH DATA-->
<Geometry x:Key="toolbarHomeButtonPathData">
    M12 5.69L17 10.19V18H15V12H9V18H7V10.19L12 5.69M12 3L2 12H5V20H11V14H13V20H19V12H22
</Geometry>

<!BASE PATH IMAGE BUTTON STYLE>
<Style x:Key="pathImageButtonStyle" 
        TargetType="{x:Type mctrls:MaroisPathImageButton}">

    <Setter Property="Background" Value="Transparent"/>
    <Setter Property="Height" Value="40"/>
    <Setter Property="Width" Value="65"/>

    <Setter Property="Template">

        <Setter.Value>

            <ControlTemplate>

                <Grid x:Name="Grid">

                    <Border x:Name="border"
                            Margin="2" 
                            Background="{TemplateBinding Background}" 
                            BorderBrush="{TemplateBinding BorderBrush}" 
                            BorderThickness="0" 
                            CornerRadius="3">

                        <StackPanel Orientation="Vertical">

                            <Path x:Name="path"
                                    Width="20"
                                    Height="20"
                                    Data="{Binding PathData, RelativeSource={RelativeSource TemplatedParent}}"
                                    Fill="{StaticResource Button.Normal.Background}"
                                    Stretch="Uniform"/>

                            <TextBlock Grid.Row="1" 
                                        Grid.Column="0" 
                                        x:Name="caption" 
                                        Text="{Binding Caption, RelativeSource={RelativeSource TemplatedParent}}"
                                        Foreground="{StaticResource Button.Normal.Background}"
                                        HorizontalAlignment="Center"
                                        VerticalAlignment="Center"
                                        Margin="0,0,0,2"/>

                        </StackPanel>

                    </Border>

                </Grid>

                <ControlTemplate.Triggers>

                    <Trigger Property="IsMouseOver" Value="true">
                        <Setter TargetName="path" Property="Fill" Value="{StaticResource Button.Normal.Foreground}" />
                        <Setter TargetName="caption" Property="Foreground" Value="{StaticResource Button.Hover.Foreground}" />
                        <Setter TargetName="border" Property="BorderBrush" Value="{StaticResource Button.Hover.Foreground}" />
                        <Setter TargetName="border" Property="BorderThickness" Value="1" />
                    </Trigger>
                    <Trigger Property="IsEnabled" Value="false">
                        <Setter TargetName="path" Property="Fill" Value="{StaticResource Button.Disabled.Foreground}" />
                        <Setter TargetName="caption" Property="Foreground" Value="{StaticResource Button.Disabled.Foreground}" />
                        <Setter TargetName="border" Property="BorderBrush" Value="{StaticResource Button.Disabled.Foreground}" />
                        <Setter TargetName="border" Property="BorderThickness" Value="1" />
                    </Trigger>

                </ControlTemplate.Triggers>

            </ControlTemplate>

        </Setter.Value>

    </Setter>

</Style>

<!TOOLBAR HOME BUTTON STYLE>
<Style x:Key="toolbarHomeButtonStyle" 
        BasedOn="{StaticResource pathImageButtonStyle }"
        TargetType="{x:Type mctrls:MaroisPathImageButton}">

    <Setter Property="Caption" Value="Home"/>
    <Setter Property="PathData" Value="{StaticResource toolbarHomeButtonPathData}"/>

</Style>
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.

QuestionDraw Images Pin
Kevin Marois4-Apr-23 14:24
professionalKevin Marois4-Apr-23 14:24 
AnswerRe: Draw Images Pin
Andy_L_J5-Apr-23 1:41
Andy_L_J5-Apr-23 1:41 
AnswerRe: Draw Images Pin
Pete O'Hanlon5-Apr-23 2:27
mvePete O'Hanlon5-Apr-23 2:27 
GeneralRe: Draw Images Pin
Kevin Marois7-Apr-23 6:31
professionalKevin Marois7-Apr-23 6:31 
GeneralRe: Draw Images Pin
Pete O'Hanlon13-Apr-23 21:41
mvePete O'Hanlon13-Apr-23 21:41 
QuestionJson Based Themes Pin
Kevin Marois6-Mar-23 6:39
professionalKevin Marois6-Mar-23 6:39 
QuestionDropDown TreeView Pin
Kevin Marois22-Feb-23 18:34
professionalKevin Marois22-Feb-23 18:34 
AnswerRe: DropDown TreeView Pin
Gerry Schmitz24-Feb-23 9:08
mveGerry Schmitz24-Feb-23 9:08 
GeneralRe: DropDown TreeView Pin
Kevin Marois2-Mar-23 11:30
professionalKevin Marois2-Mar-23 11:30 
GeneralRe: DropDown TreeView Pin
Gerry Schmitz3-Mar-23 5:25
mveGerry Schmitz3-Mar-23 5:25 
QuestionStyles aren't apply on Window element in Design Mode when they are coming from a Resource Dictionary included into a .dll reference Pin
Simos Sigma22-Feb-23 1:50
Simos Sigma22-Feb-23 1:50 
Rant[REPOST] Styles aren't apply on Window element in Design Mode when they are coming from a Resource Dictionary included into a .dll reference Pin
Richard Deeming22-Feb-23 3:51
mveRichard Deeming22-Feb-23 3:51 
GeneralRe: [REPOST] Styles aren't apply on Window element in Design Mode when they are coming from a Resource Dictionary included into a .dll reference Pin
Simos Sigma22-Feb-23 22:16
Simos Sigma22-Feb-23 22:16 
GeneralRe: [REPOST] Styles aren't apply on Window element in Design Mode when they are coming from a Resource Dictionary included into a .dll reference Pin
Simos Sigma22-Feb-23 23:46
Simos Sigma22-Feb-23 23:46 
GeneralRe: [REPOST] Styles aren't apply on Window element in Design Mode when they are coming from a Resource Dictionary included into a .dll reference Pin
Simos Sigma23-Feb-23 0:55
Simos Sigma23-Feb-23 0:55 
QuestionWPF .Net Core 6 RelayCommand Problem Pin
Kevin Marois3-Feb-23 12:33
professionalKevin Marois3-Feb-23 12:33 
AnswerRe: WPF .Net Core 6 RelayCommand Problem Pin
Richard Deeming5-Feb-23 23:18
mveRichard Deeming5-Feb-23 23:18 

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.