Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WPF
  4. Path in Style Question

Path in Style Question

Scheduled Pinned Locked Moved WPF
questiondatabasehelp
6 Posts 2 Posters 17 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    Kevin Marois
    wrote on last edited by
    #1

    Is it possible to put this path in a style? I'd like to add a data trigger to change the fill color on mouse over

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

    L 1 Reply Last reply
    0
    • K Kevin Marois

      Is it possible to put this path in a style? I'd like to add a data trigger to change the fill color on mouse over

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

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Since there's "data", it's more a resource (to be styled) than a style.

      "Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I

      K 2 Replies Last reply
      0
      • L Lost User

        Since there's "data", it's more a resource (to be styled) than a style.

        "Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I

        K Offline
        K Offline
        Kevin Marois
        wrote on last edited by
        #3

        This did it. Thanks!

            <Setter Property="Content">
                <Setter.Value>
                    <DynamicResource ResourceKey='PathKey' />
                </Setter.Value>
            </Setter>
        

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

        L 1 Reply Last reply
        0
        • K Kevin Marois

          This did it. Thanks!

              <Setter Property="Content">
                  <Setter.Value>
                      <DynamicResource ResourceKey='PathKey' />
                  </Setter.Value>
              </Setter>
          

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

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          I typically bind "Fill" or "ForeGround", etc. to an expression in the "view model" (=> ...) if it can vary from one object to the next; I use "styling" only when a group is all styled the same. (Brushes can be shared). (UWP doesn't have XAML "data triggers" so I stopped thinking about them). [How do you reference a Path stored as a resource?](https://social.msdn.microsoft.com/Forums/vstudio/en-US/59701ab4-ff79-4db5-ad36-7c5a10255159/how-do-you-reference-a-path-stored-as-a-resource?forum=wpf)

          "Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I

          K 1 Reply Last reply
          0
          • L Lost User

            I typically bind "Fill" or "ForeGround", etc. to an expression in the "view model" (=> ...) if it can vary from one object to the next; I use "styling" only when a group is all styled the same. (Brushes can be shared). (UWP doesn't have XAML "data triggers" so I stopped thinking about them). [How do you reference a Path stored as a resource?](https://social.msdn.microsoft.com/Forums/vstudio/en-US/59701ab4-ff79-4db5-ad36-7c5a10255159/how-do-you-reference-a-path-stored-as-a-resource?forum=wpf)

            "Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I

            K Offline
            K Offline
            Kevin Marois
            wrote on last edited by
            #5

            Ya, I'm going to. Ultimately it will be in a theme with data trigger to change the color for state, such as Enabled, Disabled, MouseOver, etc. Thanks

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

            1 Reply Last reply
            0
            • L Lost User

              Since there's "data", it's more a resource (to be styled) than a style.

              "Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I

              K Offline
              K Offline
              Kevin Marois
              wrote on last edited by
              #6

              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}" 
                                      Bor
              
              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups