Original question
I'm trying to make some widths in my XAML design dependent on other widths. In order to achieve this, I figured out I need to implement a binding using an IValueConverter
. Pretty much boils down to the approach from this question (or, for a more detailed post, click here).
My code is fairly simple, but it keeps yielding the following error: error C2039: 'GridViewWidthConverter': is not a member of 'MyNamespace'
. Why?
Now, the relevant part of my XAML code looks like this:
<Page
...
xmlns:local="using:MyNamespace"
...>
<!-- Horizontal scrolling grid -->
<GridView>
<GridView.Resources>
<local:GridViewWidthConverter x:Key="GridViewWidthConverter" />
</GridView.Resources>
...
</GridView>
...
</Page>
GridViewWidthConverter.h
:
#pragma once
#include "pch.h"
using namespace Platform;
using namespace Windows::UI::Xaml::Data;
using namespace Windows::UI::Xaml::Interop;
namespace MyNamespace
{
public ref class GridViewWidthConverter sealed : IValueConverter
{
public:
GridViewWidthConverter();
virtual ~GridViewWidthConverter();
virtual Object^ Convert(Object^ value, TypeName targetType, Object^ parameter, String^ language);
virtual Object^ ConvertBack(Object^ value, TypeName targetType, Object^ parameter, String^ language);
};
}
GridViewWidthConverter.cpp
:
#include "pch.h"
#include "GridViewWidthConverter.h"
using namespace MyNamespace;
// Constructor
GridViewWidthConverter::GridViewWidthConverter(){}
// Destructor
GridViewWidthConverter::~GridViewWidthConverter(){}
Object ^ GridViewWidthConverter::Convert(Object ^ value, TypeName targetType, Object ^ parameter, String ^ language)
{
return value;
}
Object ^ GridViewWidthConverter::ConvertBack(Object ^ value, TypeName targetType, Object ^ parameter, String ^ language)
{
return value;
}
Edits
The full error specification is as follows:
Error C2039: 'GridViewWidthConverter': is not a member of 'MyNamespace'
in \generated files\xamltypeinfo.g.cpp, line 200
Error C2065: 'GridViewWidthConverter': undeclared identifier
in \generated files\xamltypeinfo.g.cpp, line 200
Error C2440: 'initializing': cannot convert from 'overloaded-function' to 'Platform::Object ^(__cdecl *)(void)'
in \generated files\xamltypeinfo.g.cpp, line 252
Thanks a lot!