LiveCharts GeoMap WPF - wpf

I am trying to replicate this LiveCharts GeoMap in WPF but having an issue with the source file of my xml map :-
https://lvcharts.net/App/examples/v1/wpf/GeoHeatMap
I can produce it fine under WinForms but need to create a working version under WPF, if anyone can assist or point me in the right direction, I’m sure it’s something obvious that I’m missing?
The error I get states that the source path for my xml file doesn’t exist, when it clearly does.
If I follow the example, I create a user control, copy in the xaml plus the code behind, as per the website, then in my main window xaml, make reference to the user control. It’s at this point that it can’t load my main window as it can’t find the source file that I have referenced in my user control. In winforms I can reference it using source=#“c:\temp\world.xml” in code behind but cant do that in the xaml either. Where am I going wrong! Thanks

I had the same issue. It seems as if the NuGet package is outdated (2017).
Try to clone the LiveCharts repository and build it yourself.

In the properties of the XML file:
set Compile Action to none
In the Copy to directory:
set it to Copy Always
My Visual Studio is in Portuguese, but I think you'll get the idea.
If you're interested, there are detailed maps for each country/region; go to https://github.com/Live-Charts/Live-Maps.

Related

Could not load 'Telerik.Windows.controls.FixedDocumentViewers'

I'm working with WPF and Telerik controls. I encapsulated RadPDFViewer inside ControlTemplate (I did that before for RadGauge and it works good), after I added all the required assemblies.
In the designer(user control) I can see the component as a gray rectangle but when I run the application it gives me error as u see in the attached file and it doesn't show me the component.
When I use RadPDFViewer not inside the ControlTemplate, in regular window it works fine.
Why only 'Telerik.Windows.controls.FixedDocumentViewers' can't be loaded (BTW all my assemblies) are the same version.
Thank you
The error you are getting is obviously around missing dependencies. The information you have given is not enough to respond with a definitive answer. So I will give you a best guess
You need to ensure that you copy to the output folder the assemblies Telerik.Windows.Controls.FixedDocumentViewers has a reference to. Not all references will be required as .net only loads assemblies when it requires them.
I will assume you are using the standard binaries and not the noxaml binaries.
So, using JetBrains dotPeek (a free .net decompiler), I got the following.
Telerik.Windows.Controls.FixedDocumentViewers has a dependency on the following
Telerik.Windows.Control,
Telerik.Windows.Documents.Core and
Telerik.Windows.Documents.Fixed
Telerik.Windows.Documents.Core has a Dependency on
Telerik.Windows.Zip.
and Telerik.Windows.Documents.Fixed has a dependency on
Telerik.Windows.Documents.Core
All of the assemblies has references to the usual suspects.
Since you appear to be playing with PDF files, you may need to load Telerik.Windows.Documents.FormatProviders.Pdf and if so, it has a dependency on
Telerik Windows.Documents.
and the other dependencies are mentioned previously.
To solve your problem, I would add the first 3 to your solution (Telerik.Windows.Controls is probably already added), and then add each of the other assemblies in turn until you find what you require.
I hope this helps.
In the VS Solution Explorer, right-click the Reference and make sure Copy Local is set to True.
I solved it. It's huge solution so I have to add this assembly to the startup project.
Thanks a lot

VS2012 - Add WPF existing user control to project

This seems like it should be pretty simple but I can't seem to make it happen. Lets say I have an existing project with a user control named uc1. I would like to use this user control in another project. I right-click the project name in the solution explorer and select add>existing item, change the drop down to all files and select the files uc1.xaml and uc1.xaml.vb. This of course adds the files to the project but there is no correlation between the xaml and the code behind file and there is no way to use the control. What is the proper way of doing this?
Reed's answer is a good architectural one. If you plan on creating a control that you will reuse in many projects then it's best to use a control library.
Your original question is valid in some situations though. Say you have some source code from the Internet that you've unzipped to your drive. This project contains a .XAML file and its linked .vb file that you want to add to a project.
As you seen, the Visual Studio Solution Explorer doesn't link the files when adding with the "Add Item" dialog. I think this is a bug. I find that if I reload the project, the affiliation is added.
Here's a workaround I use. I drag the files from Windows Explorer /File Explorer onto the project in Solution Explorer. That works correctly the first time.
This of course adds the files to the project but there is no correlation between the xaml and the code behind file and there is no way to use the control. What is the proper way of doing this?
Normally, you'd add a reference to the other project, and use the UserControl directly.
This allows you to build a single project with your UserControl, and use the resulting assembly (DLL) in multiple projects without duplicating the code.
If you want to reuse your user controls you need to create a new project and choose "Class Library" from the list of available projects. When compiled this class library can easily be used by any number of other projects and solutions simply by adding a reference to compiled DLL created when you build this class library.
Edit: As mentioned in other answer it's "WPF UserControl Library", not simple "Class Library"...
You just need to add the .xaml file and VS should auto add the code behind(nested). I've seen this not work a few times and as #Walt Ritscher said this is probably a bug.
I found simply restarting Visual Studio and reloading my solution worked.

Visual Studio crashes on opening XAML file

I try and open a XAML file in a silverlight project, VS crashes.
I can create a new Silverlight project, and open XAML files in that new project no problem. However even if I create a new XAML file in my existing project VS still crashes, so my hunch is that it's not the content of the XAML, but rather something else in the project.
Any suggestions on how to troubleshoot this further before I go down the laborious task of starting with an empty but working project, and adding the bits of the existing project until it crashes.
As it turns out my DesignTime ViewModel data was the source of the problem. I inject a design-time repository that populates various collections with suitable design-time data. After a bit of refactoring that was done around the same time as the Silverlight update was applied, I messed up one of the property setters. The validator throw the exception and these caused VS to crash.
In the end I debugged this by starting a second instance of Visual Studio attaching the debugger to the first instance, and setting a bunch of breakpoints in my view model locator and design-time repository.
I debated removing this question, but decided to leave it up, with this answer as I suspect I'm not the first person to have VS crash for no apparent reason.
Deleting the ngen cache worked for me. See What causes Visual Studio 2008 SP1 to crash when switch to Design View of a WPF application
Try deleting the .suo file. You will find it where your solution file is and it will have the same name as the solution file i.e.
MySolution.sln
MySolution.suo
I just had this problem and I solved it this way :
launch the project in debug mode, try then to look at you xaml.
It worked, after closing the program everything was alright.
It's quick and safe. (you don't delete any hidden files...)
Maybe it will work for you.

Why can't I set the Image Source in WPF app?

I'm just learning WPF. I'm using VS 2008. I've added an Image control to my XAML, and I added a GIF file to the project. If I use the XAML Designer's property panel to set the image's Source property, the drop-down list for the Source property contains the following:
C:\Sample Project;component/pinHorizontal.gif
There are several problems with this:
My project, named "Sample Project," is not in the root of my drive.
Why is ";component" in there?
If I select this value as given, I get the error "Property value is not valid" (yeah, no kidding).
If I go into the XAML source and set the Source property manually, like so:
<Image Name="PinImage" Source="pinHorizontal.gif"/>
The XAML Designer gives me this error:
"The file pinHorizontal.gif is not part of the project or its 'Build Action' property is not set to 'Resource'."
Why is this task so difficult? How do I assign an image source?
Have a read through this article - though be warned it's not particularly light reading :-)
I suspect what you want for your image path is pack://application:,,,/pinHorizontal.gif. if your image is set to a BuildAction of Resource, this will work fine.
Right click on the image file(pinHorizontal.gif) in the SolutionExplorer, Go to properties, here is the 'Build Action' property, you need to set it to 'Resource'. Hope it helps!!
This post is an "and also"... not an answer to the original question.
I just thought I'd document it in case some other poor booger has this problem in future... and googling that error message finds this SO question... so here's a good place to do so.
I've been creating new icons (actually bitmaps) and adding them "on the fly" to my Visual Studio 2008 project (i.e. Add ~ Existing item). The IDE has been reporting file ${filename} is not part of the project or its 'Build Action' property is not set to 'Resource' errors on my XAML page... but my project builds and runs OK... so what gives???
I tried everything I could think of the get visual studio to refresh it's view of the filesystem, to no avail.
Well, I've just dicovered that restarting Visual Studio "refeshes" its cache of filesystem/build-output contents, which makes those annoying non-errors in the IDE go away. So I add a batch of icons, mark them all as Resources ~ Copy if newer, build, and then restart the IDE, and it's all good.
Cheers all. Keith.
In the Solution Explorer, select your project and right click rebuild the solution, and try to add the image again, it should work fine.
--or--
under the Build tab select rebuild the solution, and try to add the image again.
You can use this piece of code in the XAML to load an image from the absolute path without setting nothing. Use DecodePixelWidth or DecodePixelHeight to save application memory.
<Image>
<Image.Source>
<BitmapImage DecodePixelWidth="200" UriSource="C:\image.png" />
</Image.Source>
</Image>
Hope it helps!
I was having the exact same problem. I just manually typed in the location of the file when the Choose image box pops up and that worked for me.
I opened the Choose image box again after I got it to work and noticed that file:/// was now in front of the file location. I know next to nothing about Visual Basic (which is what I'm using) so there may be a good explanation for this, but I don't have it.

Linked Themes/Generic.xaml Files will not work in visual studio 2008

i have a project that i am doing and i need to share the code between silverlight and WPF Assembly problem is that even though the wpf assembly is the owner of that file
and the silverlight assembly only has a link to the file, all of the build actions are page everything is correct. if i make the silverlight assembly the owner then silverlight works and wpf doesnt, and currently with wpf being the owner i dont get any errors at all it just never styles the control like it cannot find it..
Note: both projects exists in the same solution.
this scenario builds and runs fine
wpf project
|__Themes
|__Generic.xaml
|__SomeControl.cs
this scenario builds and runs but will not display the control
if i change them from linked to normal it will work fine.
i just want to share this source code and not have multiple versions of the same file floating around.
SilverlightProject
|__Themes
|__"Linked"Generic.xaml
|__"Linked"SomeControl.cs
sorry for my corny Tree view representation
+++++++ UPDATE +++++++++
i have noticed when using any linked file regardless of if it is silverlight or WPF
the link file will not build into the Themes folder in the resource only the root.
i used reflector to see where my resources ended up after compilation of the assembly including the linked file and they ended up in the root , so with that being said. is there a way to prevent this or a fix for this if this is indeed non intended behavior .
i would really love to get this figured out as it has been driving me insane for a while now.
Silverlight XAML and WPF XAML do not have the same namespace - so they aren't directly reusable.
My mistake - you're right - now with Silverlight 3 the namespaces are the same:
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml
What is the Build Action in the Property Pane for the XAML?

Resources