Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Pass on button style to GraphInteractionPalette buttons

Solved!
Go to solution

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!

0 Kudos
Message 1 of 6
(4,302 Views)
Solution
Accepted by kirko7

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.

~ Paul H
Message 2 of 6
(4,292 Views)

OK, thank you for the quick feedback!

0 Kudos
Message 3 of 6
(4,290 Views)
Solution
Accepted by kirko7

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>
~ Paul H
Message 4 of 6
(2,373 Views)

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!

0 Kudos
Message 5 of 6
(2,369 Views)

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 :)).

~ Paul H
Message 6 of 6
(2,365 Views)