How i make graph in WPF Application

Apr 30, 2010 at 11:19 AM

hello sir,

 

i want to know u that how i visualize graph in WPF Application because in Windows form Application  i use elementHost to visualize the Graph But I Stuck in WPF Application

 

 

please Tell me sir i m really in a great trouble .. if you have a source code please share me sir...

 

thankz you,

 

 

 

Apr 30, 2010 at 4:38 PM
Edited Apr 30, 2010 at 4:40 PM

Here are the steps to follow to use NodeXL in a WPF application:

1. Create a new WPF Application project in Visual Studio.

2. Add references to the following assemblies:

Microsoft.NodeXL.Control.Wpf.dll
Microsoft.NodeXL.Visualization.Wpf.dll
Microsoft.NodeXL.Core.dll

3. That will add NodeXLControl to Visual Studio's Toolbox window.  Using the designer, drop a NodeXLControl onto Window1.

4. In the Properties window for Window1, add a Loaded event handler.

5. In the NodeXLApi.chm help file, go to the NodeXLControl Class topic, find the Using NodeXLControl in WPF Applications section, copy the sample code, and overwrite the entire Window1.xaml.cs file with the sample code.

6. Compile and run.  You will see a sample graph in Window1.

-- Tony

May 7, 2014 at 2:25 PM
Hello Tony,
Sorry for beginner's question.
I installed template and I can use it. Good news.
Should I download another installation in order to use nodexl in WPF? Actually, I didn't file these files on my computer...
Thank you in advance!
May 7, 2014 at 11:29 PM
Edited May 7, 2014 at 11:30 PM
rimmar:

You need to download what's called the "NodeXL Class Libraries." This download contains a set of .NET assemblies that will let you add a NodeXL graph to your own WPF application. Go to the Downloads tab at http://nodexl.codeplex.com/releases, look at the "Other Downloads" list on the right side of the page, and find the latest "NodeXL Class Libraries" release.

You can use the NodeXL Class Libraries to develop your own application at the same time you have the NodeXL Excel Template installed on your computer. They shouldn't interfere with each other.

You couldn't find the files for the NodeXL Excel Template because they are buried in what's called the ClickOnce cache. They are not in your Program Files folder. You should not try to find and use them in your own application; use the NodeXL Class Libraries for that instead.

-- Tony
May 11, 2014 at 11:50 AM
Hello Tony,
Thanks for your reply. Still have a question...
I downloaded NodeXLClassLibraries_1.0.1.320.zip. It does not contain Microsoft*.dll files you mentioned above, but it has Smrf*.dll files. Should I rename them or use them as is.
Thank you in advance,
Rimma
May 11, 2014 at 6:56 PM
Edited May 11, 2014 at 8:01 PM
Hello, Rimma:

I wrote the note you're referring to four years ago and those DLL names are now out of date. The DLLs have been renamed to the following:

Smrf.NodeXL.Control.Wpf.dll
Smrf.NodeXL.Visualization.Wpf.dll
Smrf.NodeXL.Core.dll

("SMRF" stands for "Social Media Research Foundation.")

Please do not rename anything. Use the DLLs as they are.

-- Tony
May 12, 2014 at 10:12 AM
Hello Tony,

I've added these 3 dlls, this didn't add any control to the toolbox, but I do it by myself by selecting right-click menu "Choose Items..." in the Toolbox and adding Smrf.NodeXL.Control.Wpf.dll. This added: Axis, NodeXLControland NodeXLWithAxesControl controls.
But when I'm adding anyone from this list, I've got exception: NullReferenceException: Object reference not set to an instance of an object.... View.NodeManager.CreateInstance() - constructor...

Please help,
Rimma
May 12, 2014 at 3:18 PM
Rimma:

Please do the following:

1) Make sure your Visual Studio solution is set to Debug mode, not Release mode.

2) Press F5 to debug your program.

3) When the exception is caught in Visual Studio 2013 (and in earlier versions too, I think), the "Exception was unhandled" dialog box that pops up has a "Copy exception detail to the clipboard" link. Click that link.

4) Paste the exception details here.

The exception details will include a stack trace that shows the stack of calls that led to the exception.

-- Tony
May 14, 2014 at 8:49 AM
Dear Tony,

I tried to check it more, and I found something strange:
I use some project in VS 2012, WPF, .NET 4.0. This product seems OK, all dlls and one exe are located at the same directory. I'd like to use NodeXL control inside it.
When I only put at least one Smrf*.dll to the directory of dlls, our exe crashes. In debug it gives a strange error (I'll attach it) and crashes.
Surely, when I add references to the project it crashes too...

What can be a problem with my project? Incompatible versions?

Thank you in advance,
Rimma
May 14, 2014 at 8:52 AM
It is the same for both 1.2.1.317 and 1.0.1.320 versions.
May 14, 2014 at 9:38 AM
Exception:

System.Windows.Markup.XamlParseException occurred
HResult=-2146233087
Message='The invocation of the constructor on type 'CYViewModels.ViewModels.ViewModelLocator' that matches the specified binding constraints threw an exception.' Line number '35' and line position '18'.
Source=PresentationFramework
LineNumber=35
LinePosition=18
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 ISM.Views.CaseModuleView.InitializeComponent() in C:\SW\CYD\ISM\ISM\Views\CaseModuleView.xaml:line 1
   at ISM.Views.CaseModuleView..ctor() in C:\SW\CYD\ISM\ISM\Views\CaseModuleView.xaml.cs:line 68
InnerException: System.TypeInitializationException
   HResult=-2146233036
   Message=The type initializer for 'CYViewModels.ViewModels.ViewModelLocator' threw an exception.
   Source=CYViewModels
   TypeName=CYViewModels.ViewModels.ViewModelLocator
   StackTrace:
        at CYViewModels.ViewModels.ViewModelLocator..ctor()
   InnerException: System.TypeInitializationException
        HResult=-2146233036
        Message=The type initializer for 'CYViewModels.Manager' threw an exception.
        Source=CYViewModels
        TypeName=CYViewModels.Manager
        StackTrace:
             at CYViewModels.Manager.get_DataManager()
             at CYViewModels.ViewModels.CaseContentViewModel.GetAllContentData(List`1 AllContents) in C:\SW\CYD\CYViewModels\ViewModels\CaseContentViewModel.cs:line 589
             at CYViewModels.ViewModels.QueryViewModel..ctor() in C:\SW\CYD\CYViewModels\ViewModels\QueryViewModel.cs:line 488
             at CYViewModels.ViewModels.ViewModelLocator..cctor() in C:\SW\CYD\CYViewModels\ViewModels\ViewModelLocator.cs:line 125
        InnerException: System.TypeInitializationException
             HResult=-2146233036
             Message=The type initializer for 'CYViewModels.MEFLoader' threw an exception.
             Source=CYViewModels
             TypeName=CYViewModels.MEFLoader
             StackTrace:
                  at CYViewModels.Manager..cctor() in C:\SW\CYD\CYViewModels\Manager.cs:line 52
             InnerException: System.Reflection.ReflectionTypeLoadException
                  HResult=-2146232830
                  Message=Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
                  Source=mscorlib
                  StackTrace:
                       at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
                       at System.Reflection.RuntimeModule.GetTypes()
                       at System.Reflection.Assembly.GetTypes()
                       at System.ComponentModel.Composition.Hosting.AssemblyCatalog.get_InnerCatalog()
                       at System.ComponentModel.Composition.Hosting.AssemblyCatalog.GetExports(ImportDefinition definition)
                       at System.ComponentModel.Composition.Hosting.DirectoryCatalog.<>c__DisplayClass3.<GetExports>b__2(ComposablePartCatalog catalog)
                       at System.Linq.Enumerable.<SelectManyIterator>d__14`2.MoveNext()
                       at System.ComponentModel.Composition.Hosting.CatalogExportProvider.InternalGetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition)
                       at System.ComponentModel.Composition.Hosting.CatalogExportProvider.InnerCatalogExportProvider.GetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition)
                       at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports)
                       at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExports(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports)
                       at System.ComponentModel.Composition.Hosting.CatalogExportProvider.GetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition)
                       at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports)
                       at System.ComponentModel.Composition.Hosting.ExportProvider.GetExports(ImportDefinition definition, AtomicComposition atomicComposition)
                       at System.ComponentModel.Composition.Hosting.AggregateExportProvider.GetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition)
                       at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports)
                       at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExports(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports)
                       at System.ComponentModel.Composition.Hosting.CompositionContainer.GetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition)
                       at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports)
                       at System.ComponentModel.Composition.Hosting.ExportProvider.GetExports(ImportDefinition definition, AtomicComposition atomicComposition)
                       at System.ComponentModel.Composition.Hosting.ImportEngine.TryGetExports(ExportProvider provider, ComposablePart part, ImportDefinition definition, AtomicComposition atomicComposition)
                       at System.ComponentModel.Composition.Hosting.ImportEngine.TrySatisfyImportSubset(PartManager partManager, IEnumerable`1 imports, AtomicComposition atomicComposition)
                       at System.ComponentModel.Composition.Hosting.ImportEngine.TrySatisfyImportsStateMachine(PartManager partManager, ComposablePart part)
                       at System.ComponentModel.Composition.Hosting.ImportEngine.TrySatisfyImports(PartManager partManager, ComposablePart part, Boolean shouldTrackImports)
                       at System.ComponentModel.Composition.Hosting.ImportEngine.SatisfyImports(ComposablePart part)
                       at System.ComponentModel.Composition.Hosting.ComposablePartExportProvider.<>c__DisplayClass2.<Compose>b__0()
                       at System.ComponentModel.Composition.Hosting.CompositionServices.TryInvoke(Action action)
                       at System.ComponentModel.Composition.Hosting.ComposablePartExportProvider.Compose(CompositionBatch batch)
                       at System.ComponentModel.Composition.Hosting.CompositionContainer.Compose(CompositionBatch batch)
                       at System.ComponentModel.Composition.AttributedModelServices.ComposeParts(CompositionContainer container, Object[] attributedParts)
                       at CYViewModels.MEFLoader..ctor() in C:\SW\CYD\CYViewModels\Manager.cs:line 38
                       at CYViewModels.MEFLoader..cctor() in C:\SW\CYD\CYViewModels\Manager.cs:line 31
                  InnerException:
May 14, 2014 at 10:06 AM
Update -

At the bottom of inner exceptions there was:
"Could not load file or assembly 'Smrf.NodeXL.Util, Version=1.0.1.317, Culture=neutral, .... or one of its dependencies. The system cannot find the file specified.":"Smrf.NodeXL.Util, Version=...

And I understood, that I didn't copy all files to the directory, only these 3 you mention. But I need all files from zip, and only these 3 I have to refer. Is it correct?

Thank you!
May 14, 2014 at 3:53 PM
When you add a reference to Smrf.NodeXL.Control.Wpf.dll to your project and then build it, Visual Studio automatically copies a bunch of other Smrf.NodeXL.*.dll files to your Debug or Release folder. It does that because Smrf.NodeXL.Control.Wpf.dll depends on those other DLLs, and Visual Studio detects that for you.

When you run your project, you need all of those DLLs. Are you saying that you deleted some of the DLLs? If so, that would explain why you are getting a "Could not load file or assembly 'Smrf.NodeXL.Util..." message.

-- Tony