Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Ni:graph fails in WPF with events

I a trying to create an interface that implements a Measurement Studio 2013 graph in Visual Studio 2015.

I have successfully added the graph to the form and tested it for about a week, but now I'm trying to add a custom pull out menu to the same form. If I comment out the graph, the project builds and runs as intended. If I disable the events that fire the pull out menu and add the graph back in, the program runs as intended, But if the two are on the form at the same time, I get a XAML Parse error on my last closing .

If I investigate the inner exceptions, I arrive at a NationalInstruments.Control 'Specified Method is not Supported' error.

narrowing it down further, if I removed the event trigger's SourceName property, the project builds, but of course the events no longer fire properly.

<Window.Triggers>
    <EventTrigger RoutedEvent="ToggleButton.Checked" SourceName="btnExpand">
        <BeginStoryboard Storyboard="{StaticResource ExpandisChecked}"/>
    </EventTrigger>
    <EventTrigger RoutedEvent="ToggleButton.Unchecked" SourceName="btnExpand">
        <BeginStoryboard Storyboard="{StaticResource ExpandisUnChecked}" />
    </EventTrigger>
</Window.Triggers>

Making the above into:

<Window.Triggers>
    <EventTrigger RoutedEvent="ToggleButton.Checked">
        <BeginStoryboard Storyboard="{StaticResource ExpandisChecked}"/>
    </EventTrigger>
    <EventTrigger RoutedEvent="ToggleButton.Unchecked" >
        <BeginStoryboard Storyboard="{StaticResource ExpandisUnChecked}" />
    </EventTrigger>
</Window.Triggers>

clears the error but doesn't provide functionality.

there stack trace shows:

    System.Windows.Markup.XamlParseException occurred
  HResult=-2146233087
  LineNumber=226
  LinePosition=7
  Message='Initialization of 'TEST.MainWindow' threw an exception.' Line number '226' and line position '7'.
  Source=PresentationFramework
  StackTrace:
       at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
       at System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader, Boolean skipJournaledProperties, Object rootObject, XamlAccessLevel accessLevel, Uri baseUri)
       at System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)
       at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
       at TEST.MainWindow.InitializeComponent() in C:\Users\allusers\Documents\Visual Studio 2015\Projects\TVROTR\TVROTR\MainWindow.xaml:line 1
  InnerException: 
       HResult=-2146233067
       Message=Specified method is not supported.
       Source=NationalInstruments.Controls
       StackTrace:
            at NationalInstruments.Controls.Internal.MultiEnumerator.System.Collections.IEnumerator.Reset()
            at System.Windows.LogicalTreeHelper.FindLogicalNode(DependencyObject logicalTreeNode, String elementName)
            at System.Windows.LogicalTreeHelper.FindLogicalNode(DependencyObject logicalTreeNode, String elementName)
            at System.Windows.LogicalTreeHelper.FindLogicalNode(DependencyObject logicalTreeNode, String elementName)
            at System.Windows.LogicalTreeHelper.FindLogicalNode(DependencyObject logicalTreeNode, String elementName)
            at System.Windows.FrameworkElement.FindNamedFrameworkElement(FrameworkElement startElement, String targetName)
            at System.Windows.EventTrigger.ProcessOneTrigger(FrameworkElement triggersHost, TriggerBase triggerBase)
            at System.Windows.EventTrigger.ProcessTriggerCollection(FrameworkElement triggersHost)
            at System.Windows.FrameworkElement.TryFireInitialized()
            at System.Windows.FrameworkElement.EndInit()
            at MS.Internal.Xaml.Runtime.ClrObjectRuntime.InitializationGuard(XamlType xamlType, Object obj, Boolean begin)
       InnerException: 

How can I have both on the form at the same time?

here is the full code for the window if it helps:

<Window
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:local="clr-namespace:TEST"
    xmlns:ni="http://schemas.ni.com/controls/2009/xaml/presentation" 
    x:Class="TEST.MainWindow"
    mc:Ignorable="d"
    Title="MainWindow" Height="768" Width="1024" WindowState="Maximized" WindowStyle="None">
<Window.Resources>
    <Style x:Key="ExpandCollapseToggle" TargetType="{x:Type ToggleButton}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ToggleButton}">
                    <Border x:Name="borer" BorderThickness="1" CornerRadius="2" BorderBrush="{x:Null}">
                        <Border x:Name="innerBorer" BorderThickness="1" CornerRadius="2" BorderBrush="#00FFFFFF">
                            <Grid>
                                <Grid x:Name="BGCollection" Opacity="0">
                                    <Rectangle x:Name="rectangle" Opacity="1" RadiusX="15" RadiusY="15" Stroke="{x:Null}">
                                        <Rectangle.Fill>
                                            <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                                <GradientStop Color="#FFB0B0B0" Offset="1"/>
                                                <GradientStop Color="#FF615F5F" Offset="0.553"/>
                                                <GradientStop Color="#FFD4D4D4" Offset="0"/>
                                            </LinearGradientBrush>
                                        </Rectangle.Fill>
                                    </Rectangle>                                        
                                </Grid>

                                <Path x:Name="path" Fill="{x:Null}" Stretch="Fill" HorizontalAlignment="Stretch" VerticalAlignment="Center"
                                    Height="50" Width="20" 
                                    RenderTransformOrigin="0.5,0.52" 
                                    Data="M4.5,2.0956774L8.25,5.8456774 4.5,9.5956774" Stroke="#FFEBF6FF" Margin="19.293,0,5.707,0" StrokeThickness="4">
                                    <Path.RenderTransform>
                                        <TransformGroup>
                                            <ScaleTransform ScaleX="1" ScaleY="1"/>
                                            <SkewTransform AngleX="0" AngleY="0"/>
                                            <RotateTransform Angle="0"/>
                                            <TranslateTransform X="0" Y="0"/>
                                        </TransformGroup>
                                    </Path.RenderTransform>
                                </Path>
                                <Path x:Name="path_Copy" Fill="{x:Null}" Stretch="Fill" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" 
                                    RenderTransformOrigin="0.5,0.5" 
                                    Data="M4.5,2.0956774L8.25,5.8456774 4.5,9.5956774" Stroke="#FFEBF6FF" Margin="5.218,6,9.782,6" Height="50" Width="20" StrokeThickness="4">
                                    <Path.RenderTransform>
                                        <TransformGroup>
                                            <ScaleTransform ScaleX="1" ScaleY="1"/>
                                            <SkewTransform AngleX="0" AngleY="0"/>
                                            <RotateTransform Angle="0"/>
                                            <TranslateTransform X="0" Y="0"/>
                                        </TransformGroup>
                                    </Path.RenderTransform>
                                </Path>

                            </Grid>
                        </Border>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsChecked" Value="True">
                            <Setter Property="Data" TargetName="path_Copy" Value="M6.75,2.0956774L3,5.8456774 6.75,9.5956774"/>
                            <Setter Property="Data" TargetName="path" Value="M6.75,2.0956774L3,5.8456774 6.75,9.5956774"/>
                        </Trigger>

                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsChecked" Value="false"/>
                                <Condition Property="IsMouseOver" Value="true"/>
                            </MultiTrigger.Conditions>
0 Kudos
Message 1 of 4
(2,816 Views)

Hi Whistlerone,

 

Can you clarify what you meant by custom pull out menu? Are you referring to a combo box?

 

Ren H.
Applications Engineering
National Instruments
0 Kudos
Message 2 of 4
(2,780 Views)

It looks like the test file you tried to include in your post was cut off. If you could attach the full file, or a full project, it would be very helpful for reproducing the issue locally.

 

Without being able to reproduce it locally, based just on the exception it does appear to be an issue with the child enumeration logic in the graph. To work around this, you could try to move the buttons or the graph to a separate namescope, to prevent WPF from trying to search inside the graph for the buttons. If that does not work, we could help with creating a wrapper around the base logical children enumeration in the graph to apply working reset logic.

~ Paul H
0 Kudos
Message 3 of 4
(2,734 Views)

Just wanted to let you know this issue was fixed in the Measurement Studio 2019 release.

~ Paul H
0 Kudos
Message 4 of 4
(1,840 Views)