anderZubi
anderZubi

Reputation: 6424

XAML UI updates not visible in code-behind

Having the same project opened in both, Visual Studio and Blend, I use the former to write code while I edit the XAML in the latter.

When I add an UI element to the .xaml file and save it in Blend, if I have that file opened in Visual Studio too, I see the message that some external changes have been done and asking if I want them to take effect in the opened file*. I accept it, and I can see the changes take effect in the .xaml file in Visual Studio.

The problem is, that although the new elements have been added to the .xaml file, I'm not able to access them throug Intellisense in the code-behind .cs file.

For example if I add following element to the MainPage.xaml using Blend:

<Button x:Name="MyButton" Content="Button"/>

I can see that same line added to the page in Visual Studio, but I cannot access it using the name MyButton in MainPage.xaml.cs file. Intellisense is not working for it. If I write, for example MyButton.Content = "Hello!"; it is red underlined, however I can build and run the project.

Rebuilding the project doesn't do the trick, and Intellisense doesn't work until I save the file "again" in Visual Studio.

I feel this behavior annoying sometimes, and I'd like to know if it is the normal behavior, or there is something wrong in my configuration.

*I usually don't have it opened in Visual Studio, just to avoid that meessage being shown for each modification in Blend

Upvotes: 5

Views: 1825

Answers (3)

NidhinSPradeep
NidhinSPradeep

Reputation: 1304

Closing the whole solution and re opening it fix my similar issue.

Upvotes: 0

Noel Villamor
Noel Villamor

Reputation: 1

I encountered this issue when developing Xamarin Forms in Visual Studio 2015 and somehow the problem went away after I:

1) Unload project (right-click project and select from context menu)

2) Edit .csproj (from context menu)

3) Pretend to modify and save csproj. :)

4) Reload project (from context menu)

Upvotes: 0

loop
loop

Reputation: 9242

I have just check your problem actually it is not a issue. everything is fine so what you have to do is save your xaml page on which you have added the button after accepting the changes that was done in blend..(do control + s on your xaml page one more time it will work fine)..sorry for my bad english..

Upvotes: 1

Related Questions