CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2008
    Posts
    3

    Cannot find the type 'local:CompanyViewModel'.

    I'm having this error while using HierarchicalDataTemplate control

    Error 275 Cannot find the type 'local:CompanyViewModel'. Note that type names are case sensitive. Line 12 Position 35. C:\trunk\Applications\PheonixApp\Controls\LoadOnDemandControl\LoadOnDemandControl.xaml 12 35 PheonixApp


    The CompanyViewModel class has been made to public and inherits from TreeViewItemViewModel.

    Can anyone help me out with this error? thanks

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Cannot find the type 'local:CompanyViewModel'.

    You need to define the namespace called 'local'.

    For example, the namespace named 'local' below is defined as Iridyn.Facilitator:

    Code:
     
    <UserControl x:Class="Iridyn.Facilitator.Controls.ScheduleExplorerControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:Iridyn.Facilitator"
    VerticalAlignment="Stretch" >
    <UserControl.Resources>
    <HierarchicalDataTemplate DataType="{x:Type local:ExplorerNode}"
    ItemsSource="{Binding Path=ChildNodes}">
    <Grid>
     ....
    </Grid>
    </HierarchicalDataTemplate> 
    </UserControl.Resources>


  3. #3
    Join Date
    Jun 2010
    Posts
    1

    Re: Cannot find the type 'local:CompanyViewModel'.

    been going over some sample examples from C# unleashed, and i've been stuck on this problem for awhile now. from the following code

    <Window x:Class="chapter26_A.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
    xmlns:local="clr-namespace:chapter26_A"
    Title="Window1" Height="300" Width="300">
    <Window.Resources>

    <!--<Style x:Key="labelStyle" TargetType="{x:Type Label}">
    <Setter Property="BorderThickness" Value="10" />
    <Setter Property="BorderBrush" Value="Black" />
    </Style>-->
    <ObjectDataProvider x:Key="hospitalDataSource"
    ObjectType="{x:Type local:HospitalManager}"
    MethodName="GetHospitalStaff">
    </ObjectDataProvider>
    </Window.Resources>
    </Window>

    get the following errors

    C:\Users\markdesk\Documents\practice_c#\chapter26_A\chapter26_A\Window1.xaml(14,29): error MC3050: Cannot find the type 'local:HospitalManager'. Note that type names are case sensitive. Line 14 Position 29.
    Done building project "chapter26_A.csproj" -- FAILED.
    ========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========



    i call teh function gethospitalstaff here

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Data;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Imaging;
    using System.Windows.Navigation;
    using System.Windows.Shapes;
    using System.Windows.Xps.Packaging;
    using System.IO;

    namespace chapter26_A
    {
    /// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>
    ///
    public class HospitalManager
    {
    public List<HospitalStaff> GetHospitalStaff()
    {
    return new HospitalDataContext()
    .HospitalStaffs.ToList();
    }
    }
    public partial class Window1 : Window
    {
    public Window1()
    {
    InitializeComponent();
    //dvAppDesign.Loaded +=
    //(sender, args) =>
    //{
    // dvAppDesign.Document =
    // new XpsDocument(
    // "myFile.xps",FileAccess.Read).GetFixedDocumentSequence();
    //};
    }
    private void Window_Loaded(object sender, RoutedEventArgs e)
    {

    }
    }
    }


    would appreciate any help, thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured