anderZubi anderZubi - 2 years ago 67
C# Question

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
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

Answer Source

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..

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download