03-25-2016 08:30 AM
Is there a way to pass on our custom Button style to GraphInteractionPalette?
Redesigning GraphInteractionPalette from scratch in Blend isn't something I want to persue.
Thank you!
Solved! Go to Solution.
03-25-2016 11:30 AM
Unfortunately, the template for the graph interaction palette uses a fixed style to configure the buttons. I have created a task to address this in a future Measurement Studio release.
As a workaround, you can use the skin example in the attached XAML file as a starting point.
03-25-2016 11:37 AM
OK, thank you for the quick feedback!
07-08-2019 03:15 PM
Just wanted to let you know that Measurement Studio 2019 added a ButtonStyle property to control this directly:
<ni:GraphInteractionPalette>
<ni:GraphInteractionPalette.ButtonStyle>
<Style TargetType="ButtonBase">
<Setter Property="Width" Value="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ni:GraphInteractionPalette}}, Path=ButtonSize.Width}" />
<Setter Property="Height" Value="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ni:GraphInteractionPalette}}, Path=ButtonSize.Height}" />
<Setter Property="Padding" Value="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ni:GraphInteractionPalette}}, Path=Padding}" />
<Setter Property="ToolTipService.ToolTip" Value="{Binding}" />
<Setter Property="Content" Value="{Binding}" />
<Setter Property="ContentTemplateSelector">
<Setter.Value>
<niPrimitives:NamedTemplateSelector />
</Setter.Value>
</Setter>
<!-- style customization -->
<Setter Property="Background" Value="LightGreen" />
<!-- style customization -->
</Style>
</ni:GraphInteractionPalette.ButtonStyle>
</ni:GraphInteractionPalette>
As you can see, this still requires duplication of standard bindings to get standard behavior. This can be simplified with some code to pull in the default button style:
Code:
public MainWindow()
{
var defaultPaletteStyle = (Style)this.FindResource(typeof(GraphInteractionPalette));
var baseButtonStyle = defaultPaletteStyle.Resources.Values.OfType<Style>().Single(s => typeof(ButtonBase).IsAssignableFrom(s.TargetType));
this.Resources["BaseButtonStyle"] = baseButtonStyle;
InitializeComponent();
}
XAML:
<ni:GraphInteractionPalette>
<ni:GraphInteractionPalette.ButtonStyle>
<Style TargetType="ButtonBase" BasedOn="{StaticResource BaseButtonStyle}">
<!-- style customization -->
<Setter Property="Background" Value="LightGreen" />
<!-- style customization -->
</Style>
</ni:GraphInteractionPalette.ButtonStyle>
</ni:GraphInteractionPalette>
07-08-2019 03:42 PM
Thank you, Paul!
I actually just realized that 2019 is out and was wondering what changes were made. I mean, I see the release notes but there isn't much unless I'm looking at a wrong link.
I will have to order 2019 then.
Thanks!
07-08-2019 04:12 PM
Specifically for the WPF controls, the 2019 release was focused primarily on performance and bug fixes (so fewer high-level things to announce; it just works better :)).