Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Graph Name and Legend color settings

Solved!
Go to solution

Ha!  So I copied the exact code I pasted (the one you said worked for you) and I don't get the error at ni: Plot

BUT, I get this error now...

 

Error 1 The namespace prefix "niPrimitives" is not defined.

 

We are getting really close LOL.  Is there something I need to define?  

Thanks!

0 Kudos
Message 11 of 15
(3,353 Views)
Solution
Accepted by topic author kirko7

Yes, niPrimitives is another schema-based namespace:


xmlns:niPrimitives="http://schemas.ni.com/controls/2009/xaml/presentation/primitives"

~ Paul H
0 Kudos
Message 12 of 15
(3,349 Views)

Nice!  Thank you...  I got this to work.

Altough the toggle button for every plot is not there anymore but I don't think I will need it (at least not now).

 

0 Kudos
Message 13 of 15
(3,347 Views)

@phansen wrote:

Since you are generated plots in code, it may make more sense for you to override the default legend template for plots instead:


    <DataTemplate DataType="{x:Type ni:Plot}">
        <StackPanel Orientation="Horizontal">
            <niPrimitives:LegendGlyph Margin="3"
                    Renderer="{Binding ActualRenderer}"
                    Background="{Binding ItemBackground, RelativeSource={RelativeSource AncestorType={x:Type ni:Legend}, Mode=FindAncestor}}"
                    Width="{Binding GlyphSize.Width, RelativeSource={RelativeSource AncestorType={x:Type ni:Legend}, Mode=FindAncestor}}"
                    Height="{Binding GlyphSize.Height, RelativeSource={RelativeSource AncestorType={x:Type ni:Legend}, Mode=FindAncestor}}" />

            <ContentPresenter Margin="3"
                    VerticalAlignment="Center"
                    Content="{Binding Label}" />
        </StackPanel>
    </DataTemplate>


Hi Paul.  

Here I am more than a year later 🙂

Could you please post same XAML DataTemplate but only this time include the ToggleButton control?  I would like to try and substitute ToggleButton (that looks like default Windows style) with custom CheckMark.  So I need the complete DataTemplate to see how Plot visibility is bound to ToggleButton.

Thank you in advance!

 

 

0 Kudos
Message 14 of 15
(1,945 Views)

Plot visibility is handled specifically by binding IsChecked on the ToggleButton to the plot's Visibility with {Binding Visibility, Converter={StaticResource VisibilityToBoolean}}, which uses this converter:


    <niPrimitives:MatchedValueConverter x:Key="VisibilityToBoolean" DefaultValue="Collapsed" DefaultResult="False">
        <niPrimitives:MatchPair Value="Visible" Result="True" />
    </niPrimitives:MatchedValueConverter>



If you are interested, here is the full style we use on the ToggleButton:


    <Style x:Key="LegendGlyphVisibilityToggle" TargetType="{x:Type ToggleButton}">
        <Setter Property="Width" Value="{Binding GlyphSize.Width, RelativeSource={RelativeSource AncestorType={x:Type ni:Legend},Mode=FindAncestor}}" />
        <Setter Property="Height" Value="{Binding GlyphSize.Height, RelativeSource={RelativeSource AncestorType={x:Type ni:Legend}, Mode=FindAncestor}}" />
        <Setter Property="Margin" Value="3" />
        <Setter Property="Padding" Value="1" />
        <Setter Property="HorizontalContentAlignment" Value="Center" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="IsChecked" Value="{Binding Visibility, Converter={StaticResource VisibilityToBoolean}}" />
    </Style>


The ToggleButton itself just wraps the legend glyph from the earlier template.

~ Paul H
0 Kudos
Message 15 of 15
(1,940 Views)