Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WPF
  4. GridViewColumn DataTemplate

GridViewColumn DataTemplate

Scheduled Pinned Locked Moved WPF
csharphtmldotnetvisual-studiocom
12 Posts 2 Posters 36 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T teejayem

    I am working in the latest preview of blend 2 and i am getting an error that i can't seem to figure out. I have a data template for a gridview column and i am the following error: Mapping URI 'clr-namespace:Ups_Trak_System;assembly=Ups Trak System' is not valid. However, in visual studio it compiles fine w/o any errors. When i take out the Foreground attribute the error goes away so i'm thinking that it somehow can't find the "BrushConverter". Could someone please take a look at this Image[^] of the markup and see if i am doing it right? i would have just posted the markup but when i previewed it it wouldn't display correctly.

    Don't be overcome by evil, but overcome evil with good

    L Offline
    L Offline
    Lost User
    wrote on last edited by
    #2

    I noticed that you're setting the Path to "*". Any reason you not setting the Path to a DependencyProperty name?

    Cheers, Karl My Blog | Mole's Home Page | How To Create Screen Capture Videos For Your Articles

    Just a grain of sand on the worlds beaches.

    T 1 Reply Last reply
    0
    • L Lost User

      I noticed that you're setting the Path to "*". Any reason you not setting the Path to a DependencyProperty name?

      Cheers, Karl My Blog | Mole's Home Page | How To Create Screen Capture Videos For Your Articles

      Just a grain of sand on the worlds beaches.

      T Offline
      T Offline
      teejayem
      wrote on last edited by
      #3

      Hey Karl (btw mole rocks!), When determining the foreground color i have to look at a couple properties of the object that i am binding to the listview. I found that adding 'Path=.' or 'Path=*' will pass the entire object to the converter class. Just to be sure, I tried it with 'Path=Status' but it didn't resolve the issue.

      Don't be overcome by evil, but overcome evil with good

      L 1 Reply Last reply
      0
      • T teejayem

        Hey Karl (btw mole rocks!), When determining the foreground color i have to look at a couple properties of the object that i am binding to the listview. I found that adding 'Path=.' or 'Path=*' will pass the entire object to the converter class. Just to be sure, I tried it with 'Path=Status' but it didn't resolve the issue.

        Don't be overcome by evil, but overcome evil with good

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #4

        Thanks for the comments on Mole, really appreciate them. I just learned more about the WPF Path statement too, thanks! :cool: Can you posted your XAML and Converter code here or just make a screen shot and provide a link so that I can see everything in context. I'm out for about 2 hours but will get back to you when I return.

        Cheers, Karl My Blog | Mole's Home Page | How To Create Screen Capture Videos For Your Articles

        Just a grain of sand on the worlds beaches.

        T 1 Reply Last reply
        0
        • L Lost User

          Thanks for the comments on Mole, really appreciate them. I just learned more about the WPF Path statement too, thanks! :cool: Can you posted your XAML and Converter code here or just make a screen shot and provide a link so that I can see everything in context. I'm out for about 2 hours but will get back to you when I return.

          Cheers, Karl My Blog | Mole's Home Page | How To Create Screen Capture Videos For Your Articles

          Just a grain of sand on the worlds beaches.

          T Offline
          T Offline
          teejayem
          wrote on last edited by
          #5

          Here you go (thanks again).

          using System;
          using System.Windows.Media;
          using System.Windows.Data;

          namespace Ups_Trak_System
          {
          public class BrushConverter : IValueConverter
          {
          #region IValueConverter Members

              public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
              {
                  SalesAssociate associate = value as SalesAssociate;
                  if (associate == null) return Brushes.Black;
          
                  if (associate.Status.Contains("WITH")) return Brushes.DarkGreen;
                  else if (associate.Status.Contains("LUNCH")) return Brushes.Blue;
                  else if (associate.Status.Contains("GUEST")) return Brushes.DarkOrange;
                  else if (associate.Status.Contains("OFF") && !String.IsNullOrEmpty(associate.ClockOut)) return Brushes.DarkRed;
          
                  return Brushes.Black;
              }
          
              public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
              {
                  throw new NotImplementedException();
              }
          
              #endregion
          }
          

          }

          Don't be overcome by evil, but overcome evil with good

          L 1 Reply Last reply
          0
          • T teejayem

            Here you go (thanks again).

            using System;
            using System.Windows.Media;
            using System.Windows.Data;

            namespace Ups_Trak_System
            {
            public class BrushConverter : IValueConverter
            {
            #region IValueConverter Members

                public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
                {
                    SalesAssociate associate = value as SalesAssociate;
                    if (associate == null) return Brushes.Black;
            
                    if (associate.Status.Contains("WITH")) return Brushes.DarkGreen;
                    else if (associate.Status.Contains("LUNCH")) return Brushes.Blue;
                    else if (associate.Status.Contains("GUEST")) return Brushes.DarkOrange;
                    else if (associate.Status.Contains("OFF") && !String.IsNullOrEmpty(associate.ClockOut)) return Brushes.DarkRed;
            
                    return Brushes.Black;
                }
            
                public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
                {
                    throw new NotImplementedException();
                }
            
                #endregion
            }
            

            }

            Don't be overcome by evil, but overcome evil with good

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #6

            Can you post the XAML code too.

            Cheers, Karl My Blog | Mole's Home Page | How To Create Screen Capture Videos For Your Articles

            Just a grain of sand on the worlds beaches.

            T 1 Reply Last reply
            0
            • L Lost User

              Can you post the XAML code too.

              Cheers, Karl My Blog | Mole's Home Page | How To Create Screen Capture Videos For Your Articles

              Just a grain of sand on the worlds beaches.

              T Offline
              T Offline
              teejayem
              wrote on last edited by
              #7

              Here you Go[^]. Sorry about that.

              Don't be overcome by evil, but overcome evil with good

              L 1 Reply Last reply
              0
              • T teejayem

                Here you Go[^]. Sorry about that.

                Don't be overcome by evil, but overcome evil with good

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #8

                I have built a C# project just like yours and it is working here. Didn't have any issues. What is the exact message you are getting from the Blend?

                Cheers, Karl My Blog | Mole's Home Page | How To Create Screen Capture Videos For Your Articles

                Just a grain of sand on the worlds beaches.

                T 1 Reply Last reply
                0
                • L Lost User

                  I have built a C# project just like yours and it is working here. Didn't have any issues. What is the exact message you are getting from the Blend?

                  Cheers, Karl My Blog | Mole's Home Page | How To Create Screen Capture Videos For Your Articles

                  Just a grain of sand on the worlds beaches.

                  T Offline
                  T Offline
                  teejayem
                  wrote on last edited by
                  #9

                  Here[^] Is the error message i am getting in blend. If you see the xaml screenshot posted earlier you'll see where the errors are. However, the DataTemplate does actually work and build. but with these errors i can't go rightclick on the listview and edit the other templates or styles.

                  Don't be overcome by evil, but overcome evil with good

                  L 1 Reply Last reply
                  0
                  • T teejayem

                    Here[^] Is the error message i am getting in blend. If you see the xaml screenshot posted earlier you'll see where the errors are. However, the DataTemplate does actually work and build. but with these errors i can't go rightclick on the listview and edit the other templates or styles.

                    Don't be overcome by evil, but overcome evil with good

                    L Offline
                    L Offline
                    Lost User
                    wrote on last edited by
                    #10

                    I see what's up. Your assembly name is, "Ups Trak System" Your namespace is, "Ups_Trak_System" What is the name of your output .dll? Suggestion. Name your assembly and name space either, "UpsTrakSystem" or "Ups_Trak_System" This may be where Blend is all confused.

                    Cheers, Karl My Blog | Mole's Home Page | How To Create Screen Capture Videos For Your Articles

                    Just a grain of sand on the worlds beaches.

                    T 1 Reply Last reply
                    0
                    • L Lost User

                      I see what's up. Your assembly name is, "Ups Trak System" Your namespace is, "Ups_Trak_System" What is the name of your output .dll? Suggestion. Name your assembly and name space either, "UpsTrakSystem" or "Ups_Trak_System" This may be where Blend is all confused.

                      Cheers, Karl My Blog | Mole's Home Page | How To Create Screen Capture Videos For Your Articles

                      Just a grain of sand on the worlds beaches.

                      T Offline
                      T Offline
                      teejayem
                      wrote on last edited by
                      #11

                      Karl, you are the man! I changed the assembly to "Ups", recompiled it, and opened it in blend and it displayed the listviews correctly w/ no errors. Blend doesn't like spaces in the assembly name. Thank you so much for your help i would have never figured it out!

                      Don't be overcome by evil, but overcome evil with good

                      L 1 Reply Last reply
                      0
                      • T teejayem

                        Karl, you are the man! I changed the assembly to "Ups", recompiled it, and opened it in blend and it displayed the listviews correctly w/ no errors. Blend doesn't like spaces in the assembly name. Thank you so much for your help i would have never figured it out!

                        Don't be overcome by evil, but overcome evil with good

                        L Offline
                        L Offline
                        Lost User
                        wrote on last edited by
                        #12

                        Cool. I'm glad we got this sorted out. :cool:

                        teejayem wrote:

                        Don't be overcome by evil, but overcome evil with good

                        Love this too. Have a great day,

                        Cheers, Karl My Blog | Mole's Home Page | How To Create Screen Capture Videos For Your Articles

                        Just a grain of sand on the worlds beaches.

                        1 Reply Last reply
                        0
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • World
                        • Users
                        • Groups