M.Prajyot

Hi

I have created Browser Application in WPF 3.0 .

When I compiled this application Its giving Compilation error like

"Error 8 The name ' theImage' does not exist in the current context "

Here " theImage " is controls name .This is error coming for all controls in that Application .

I also added references of presentation., presentation.framework,windows.base these dll




Re: Windows Presentation Foundation (WPF) Compilation Error "The name ' anycontrol' does not exist in the current context "in Browser Application in WPF ?

Yi-Lun Luo - MSFT

To give a name for a control, we use the syntax:

<Image Name="theImage">

Are you using that






Re: Windows Presentation Foundation (WPF) Compilation Error "The name ' anycontrol' does not exist in the current context "in Browser Application in WPF ?

M.Prajyot

Already I am using the same syntax but its still giving same error

Thanks

M . Prajyot






Re: Windows Presentation Foundation (WPF) Compilation Error "The name ' anycontrol' does not exist in the current context "in Browser Application in WPF ?

andysteve

Hi, i am also having the same problem. I have given my element a name in the correct format in xaml, yet in the code behind the name is not recognised and i get the complier error;

Error 20 The name 'sp1' does not exist in the current context

my xaml;

<StackPanel Name="sp1">
<.../>
</StackPanel>

i should make note that this is within a WPF3d visual. It is also within a listbox control.







Re: Windows Presentation Foundation (WPF) Compilation Error "The name ' anycontrol' does not exist in the current context "in Browser Application in WPF ?

Tony B

Posting your xaml might make it easier for people to figure out the problem...



Re: Windows Presentation Foundation (WPF) Compilation Error "The name ' anycontrol' does not exist in the current context "in Browser Application in WPF ?

andysteve

heres my xaml. I have found that the problem seems to lie within the listbox control. When i removed the list box control but kept its content, then the name property is recognised. How do i use 'Name' property within a listbox seems to be the question......

<ListBox x:Name="listbox3" ItemsSource="{Binding Source={StaticResource imageCollection}, XPath=Image}"

SelectedValuePath="File">

<ListBox.ItemsPanel>

<ItemsPanelTemplate>

<StackPanel Orientation="Horizontal"/>

</ItemsPanelTemplate>

</ListBox.ItemsPanel>

<ListBox.ItemTemplate>

<DataTemplate>

<DockPanel>

<Image DockPanel.Dock="Right" Source="{Binding XPath=File}"/>

<ScrollViewer CanContentScroll="True" Name="sv1">

<StackPanel Name="sp1">

<UniformGrid Rows="2" VerticalAlignment="Center" Name="uniGrid">

<TextBlock FontSize="72" Text="{Binding XPath=@Name}" HorizontalAlignment="Center" VerticalAlignment="Bottom"></TextBlock>

<TextBlock MaxWidth="400" MinWidth="400" MaxHeight="400" MinHeight="400" TextWrapping="Wrap" Name="infoText" FontSize="{Binding ElementName=fontSizeSlide, Path=Value}" Text="{Binding XPath=Text}" HorizontalAlignment="Center" VerticalAlignment="Bottom"/>

</UniformGrid>

</StackPanel>

</ScrollViewer>

</DockPanel>

</DataTemplate>

</ListBox.ItemTemplate>

</ListBox>





Re: Windows Presentation Foundation (WPF) Compilation Error "The name ' anycontrol' does not exist in the current context "in Browser Application in WPF ?

andysteve

Just to add to my previous post, i still haven't found why the 'Name' property is not recognised within code behind. i'm starting to think that the error is caused because the elements are in a data template. The name 'sp1' IS recognised within xaml when using data triggers, but it seems that this is the only place where it is recognised. Can anyone help me in determining why this is the case I need to use the 'Name' in the code behind so that i can use it to add interactivity to the scroll viewer. Thanks



Re: Windows Presentation Foundation (WPF) Compilation Error "The name ' anycontrol' does not exist in the current context "in Browser Application in WPF ?

Richard Morgan

I'm not sure why you're using "x:Name" when giving your listbox a name. Have you just tried using Name="listbox3" in your XAML



Re: Windows Presentation Foundation (WPF) Compilation Error "The name ' anycontrol' does not exist in the current context "in Browser Application in WPF ?

M.Prajyot

I am using same like

<ComboBox Name="theCombo">

Still its not working






Re: Windows Presentation Foundation (WPF) Compilation Error "The name ' anycontrol' does not exist in the current context "in Browser Application in WPF ?

andysteve

Just to add here, I couldnt find a soloution for the errors. Previously i thought that it could have been to do with datatemplate or scrollviewer or listbox. Another problem might have been found as though content was being used as a resource. I had a stackpanel with an x:Key and its content was everything in the code posted previously by me. This resource key was being called as a interactiveVisual3D.Visual.

Like i said, i didnt come to a soloution, so i took a different approach to the problem. However, if anyone does have an explnation for this then i would indeed like to know.

Thanks





Re: Windows Presentation Foundation (WPF) Compilation Error "The name ' anycontrol' does not exist in the current context "in Browser Application in WPF ?

Tamir Khason

The explanation is simple, you can not use Name property on something, that actually does not exists. If you're using resources, use Keys, not Names. this way you (and framework) will be able to find and use them. Not by names