Path in Style Question
-
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.
-
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.
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
-
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
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.
-
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.
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
-
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
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.
-
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
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