Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / April 2007

Tip: Looking for answers? Try searching our database.

Name Visability in XAML & Code Behind

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
hufaunder@yahoo.com - 21 Apr 2007 00:08 GMT
In XAML you can give a name to each element so you can access it in
the code behind file. This works fine for a WPF application but not a
Windows Form application. Here is what I do:

1) Create a new WinForm application project
2) Add a new WPF User Control
3) In the XAML file give the grid a name, i.e. <grid Name="grid1">
4) In the code behind file trying to add this.grid1 but it's not
picked up.

Another strange thing is that when I try to compile the project it
does not see InitializeComponent. It says "The name
InitializeComponent does not exist in the current context". I guess
the two problem are related but how do I get it to work?

Again, if in 1) I create a WPF project everything works just fine.

Thanks
Deniz Demircioglu - 22 Apr 2007 19:54 GMT
1. From command line, go to project folder
2. Notepad .csproj (or "vbproj")
3. In the csproj file, find this line:
 <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
4. Under this line, add the following line:
 <Import Project="$(MSBuildBinPath)\Microsoft.WinFx.targets" />
5. Now your project should compile without saying 'cannot find Initialize
Component'
6. After the first compile, you should be able to access the elements
defined in Xaml by using their name from code behind.

Thx

Signature

Developer,
Microsoft Office

> In XAML you can give a name to each element so you can access it in
> the code behind file. This works fine for a WPF application but not a
[quoted text clipped - 14 lines]
>
> Thanks
hufaunder@yahoo.com - 23 Apr 2007 00:29 GMT
On Apr 22, 11:54 am, Deniz Demircioglu
<DenizDemircio...@discussions.microsoft.com> wrote:
> 1. From command line, go to project folder
> 2. Notepad .csproj (or "vbproj")
[quoted text clipped - 34 lines]
>
> - Show quoted text -

Wow, thanks. Don't know how I would have figured that out...

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.