Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF Designer says "Build the Project to update Design view" while not needed

Tags:

c#

wpf

So this photo is pretty self explaining itself:

enter image description here

The RowNumberConverter DOES exist in the same namespace but Visual Studio stupidly says that it doesn't! I did clean the solution and the app builds and runs with no problems but I can't see the designer! And all of this happened suddenly with no reason no idea why!

BTW that's a converter class for showing row numbers in an EntityFramework-binded DataGrid.

‌ ‌ ‌ Update:

Converter file (RowNumberConverter.cs):

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

namespace MyProject
{
    class RowNumberConverter : IMultiValueConverter
    {
        #region IMultiValueConverter Members

        public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {

            //get the grid and the item
            Object item = values[0];
            DataGrid grid = values[1] as DataGrid;

            int index = grid.Items.IndexOf(item);

            return (index < 0) ? "" : (index + 1).ToString();
        }

        public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }

        #endregion
    }
}
like image 766
ParSa Avatar asked Nov 30 '22 08:11

ParSa


1 Answers

This has been an issue w/ VS for a long, long time. You need to set the build type to be "Any CPU" or x86, anything that is NOT x64. This is because (for reasons nobody understands), since VS is built from x86 code, it cannot show and display x64 code in the designer. Switch (temporarily) your project to x86, recompile, and presto, it will show up!

like image 183
eric frazer Avatar answered Dec 05 '22 05:12

eric frazer