Click here to Skip to main content
15,891,699 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have the following code in App.xaml:

HTML
<Application x:Class="eesPhotography.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:u="clr-namespace:eesUtilities"
             xmlns:local="clr-namespace:eesPhotography"
             StartupUri="MainWindow.xaml">
    <Application.Resources>
       
        <u:DateConverter x:Key="DateConverter"/>


When I typed in u: intellisense displayed DateConverter, which I selected and then completed the code. However, it's displaying a message:

The name DateConverter does not exist in the namespace 'clr-namespace:Utilities'

What am I doing wrong?
Posted
Comments
Richard Deeming 14-Oct-15 11:35am    
Is there a class called DateConverter in the namespace eesUtilities defined in the current project? Or is it defined in a different assembly?
Maciej Los 14-Oct-15 12:28pm    
Robert, you have to provide more details about your issue. Did you download specific example from this site? Is it a MSDN example or something?
Robert Kamarowski 14-Oct-15 13:30pm    
DateConverter is defined in the current project. Code follows:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Globalization;

namespace eesUtilities
{
internal class DateConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value != null)
return ((DateTime)value).ToShortDateString();
return String.Empty;
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
string strValue = value.ToString();
DateTime resultDateTime;
return DateTime.TryParse(strValue, out resultDateTime) ? resultDateTime : value;
}
}
}

I want to use this DateConverter for a DatePicker control. I thought this was how I made it available.
Richard Deeming 14-Oct-15 17:22pm    
If it's in the same project, and it's a standard WPF application, then it should be OK.

Are you getting the error at runtime, compile-time, or in the designer? If it's in the designer, try compiling your project to see if it resolves the error.

You might also want to try making the class public instead of internal.
Robert Kamarowski 15-Oct-15 13:08pm    
Thank you Richard. Leaving for vacation, so I'll try it when I return.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900