简体   繁体   中英

Problems with converting WPF project from C# to VB.NET

I'm very new in WPF world and I want to translate a C# project to VB.NET since it has many features that I want to reuse. I'm using VS 2013. C# project is from this source: https://github.com/Julien-Marcou/RadialMenu It is a CustomControl WPF project.

I've get the following error: Cannot find the type 'Controls:PieShape'. Note that type names are case sensitive.

I think is still a namespace reference problem, but it is odd since I used all the original project names and namespaces.
I need your help !

In both C# (original) and VB.NET (mine) projects we have:
- 1) Project properties:
Assembly name: RadialMenu
Root namespace: RadialMenu
- 2) Generic.xaml:
(replaced tags with curlies...)

{ResourceDictionary   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"}
{ResourceDictionary.MergedDictionaries}
{ResourceDictionary Source="/RadialMenu;component/Themes/PieShape.xaml" /} -here is an error only in VB.NET project:
    **An error occurred while finding the resource dictionary "/RadialMenu;component/Themes/PieShape.xaml"**.
{ResourceDictionary Source="/RadialMenu;component/Themes/RadialMenu.xaml" /}
{ResourceDictionary Source="/RadialMenu;component/Themes/RadialMenuCentralItem.xaml" /}
                {ResourceDictionary Source="/RadialMenu;component/Themes/RadialMenuItem.xaml" /}
           {/ResourceDictionary.MergedDictionaries}

{/ResourceDictionary}
  • 3) PieShape.xaml : (replaced tags with curlies...)

      {ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:Controls="clr-namespace:RadialMenu.Controls"} {Style TargetType="Controls:PieShape" /} -here is an error only in VB.NET code: **Cannot find the type 'Controls:PieShape'. Note that type names are case sensitive.** {/ResourceDictionary} 

PieShape.vb (code)

    Imports System.Windows
    Imports System.Windows.Media
    Imports System.Windows.Shapes
    namespace RadialMenu.Controls
    Public Class PieShape
        Inherits Shape '...

PieShape.cs (code)

 using System;
    using System.Windows;
    using System.Windows.Media;
    using System.Windows.Shapes;

    namespace RadialMenu.Controls
    {
    internal class PieShape : Shape
    {//...
  • 4) RadialMenu.xaml - both projects (replaced tags with curlies...)

     {ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:Controls="clr-namespace:RadialMenu.Controls"} 
     {Style TargetType="Controls:RadialMenu"} - here is an error only in vb.net **The name "RadialMenu" does not exist in the namespace "clr-namespace:RadialMenu.Controls"**. 
    \n\n... \n

There are another files with errors (RadialMenuItem.xaml etc.) but since they use PieShape.xaml, if it is an error in this file all others have an error, so it is normal.

How to eliminate the error from PieShape.xaml file ? I've tried a lot of ~solutions~ found in stackoverflow: - restart project - replace x86 with x64 and back to x86.

It is a problem with namespaces in visual basic.net ?

Thank you very much !

Resolved: I had to replace the namespace name

namespace RadialMenu.Controls

with this name

namespace Controls

I don't know why it works...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM