locked
How do I use a value converter that's in another project? RRS feed

  • Question

  • Hello,

    I'm using Blend 4, and want to use a value converter to format some data. In order to be able to reuse the value converter, I want to put it (and the others that will inevitably follow) in a separate project.

    In Visual Studio 2010, I created a class library project, and added my first VC. I then added a reference to this project from the WPF project I was writing.

    I then switched to Blend, and tried to use the converter. However, when I clicked the little "..." button by the VC dropdown, it showed me a load of VCs for other assemblies in the solution (Telerik controls, etc), but didn't show my own VC.

    I've searched around, but can't find an answer to this one. I would be very grateful if anyone can help me.

    Thanks in advance


    If you're really bored, you could read about my experiments with .NET and some of Microsoft's newer technologies at http://dotnetwhatnot.pixata.co.uk/
    Thursday, January 27, 2011 11:12 PM

Answers

All replies

  • Did you build the project in Blend? Blend won't display any VC that aren't yet built because it doesn't know about them. Be sure you reloaded the sln in Blend (to pick up the new project) and built at least once.
    Friday, January 28, 2011 2:03 PM
    Moderator
  • Hi Chuck,

    Yup, I built it several times. I was able to set the value converter in VS, but Blend wouldn't pick up on it at all.

    Any ideas? Thanks for the reply.


    If you're really bored, you could read about my experiments with .NET and some of Microsoft's newer technologies at http://dotnetwhatnot.pixata.co.uk/
    Sunday, January 30, 2011 4:02 PM
  • Actually, I spoke too soon. I just realised that the one that works in VS is one I added to the same project. The one I added in a separate project doesn't work from VS either, so it looks like it's not a Blend issue at all. It looks like I need to work out why my WPF project can't see the converter.

    I'd still be grateful for any suggestions.


    If you're really bored, you could read about my experiments with .NET and some of Microsoft's newer technologies at http://dotnetwhatnot.pixata.co.uk/
    Sunday, January 30, 2011 4:28 PM
  • I'll see if I can replicate what is happening to you when I get back to the office Mon. If I can't, are you able to share the project so I could try to replicate the issue?

     

    Sunday, January 30, 2011 4:29 PM
    Moderator
  • Hi again Chuck,

    Unfortunately this project is a monster! It's got about 12 separate projects, including repositories, entities, WCF services, old uncle Tom Cobbly and all!

    I'll see if I can repro the problem on a small project, and is fo, I will happily share that with you. Where should I send it?


    If you're really bored, you could read about my experiments with .NET and some of Microsoft's newer technologies at http://dotnetwhatnot.pixata.co.uk/
    Sunday, January 30, 2011 4:31 PM
  • OK, so having wasted more time than I should, I realised that the basic problem seems to be getting the XAML to recognise a value converter in another project.

    My guess is that I need to have some sort of xmlns line at the top of the XAML that tells it about the referenced DLL that has the value converters. I got stuck trying to do this, as whatever I added, I got errors.

    I'd be really grateful if you could put together a small project that shows how to do this as I'm stuck!

    Thanks


    If you're really bored, you could read about my experiments with .NET and some of Microsoft's newer technologies at http://dotnetwhatnot.pixata.co.uk/
    Sunday, January 30, 2011 5:02 PM
  • In case it helps anyone, I found the answer due to help someone gave in another forum. If you want to see the full instructions for how to do this, look at http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/478d6b47-fbc4-4d88-b386-dd6a3ca57276 and scroll down to my last post. I detailed it all there.

    Thanks to everyone who helped.


    If you're really bored, you could read about my experiments with .NET and some of Microsoft's newer technologies at http://dotnetwhatnot.pixata.co.uk/
    • Marked as answer by Mr Yossu Monday, January 31, 2011 2:12 PM
    Monday, January 31, 2011 2:11 PM