This is a migrated thread and some comments may be shown as answers.

Cant acces xaml objects in c#

2 Answers 309 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
tyler
Top achievements
Rank 1
tyler asked on 20 Feb 2018, 09:10 PM

Hello iam trying out your ui controls,

i seem have to run into a little issue when i put any telerik object in xaml designer everything seems to be fine.Once i try to reference the xaml object in c# code through intellisense the telerik object name wont show up in the list.However i can still call the object in c# for example telerikObj.Axis; it says telerikObj doesnt exists in the context but if i compile with errors and run the program it works as expected.There is one error that i cant seem to get rid of either inside the StartPage.xaml.cs file it says InitializeComponent(); doesnt exists in the context as well.Everything runs fine but seems to have these issues.What did i do wrong?Thanks

2 Answers, 1 is accepted

Sort by
0
Lance | Manager Technical Support
Telerik team
answered on 22 Feb 2018, 12:34 AM
Hello Tyler,

This is unrelated to UI for Xamarin, rather it's a known issue with the way Visual Studio IntelliSense is with Xamarin.Forms applications. This is primarily because Xamarin.Forms markup is an xml file that doesn't have full XAML IntelliSense capabilities that you'd get when doing UWP or WPF.

Most of the time, the false errors in C# will go away of you save the XAML file first. If that doesn't work, then try closing and reopening the file. Ultimately, if you can compile, the errors are false.

Tip

Make sure you have Xamarin.Forms XAML Compilation (aka "XamlC") enabled for the solution  so that when you compile, you'll catch any XAML errors at build time instead of at runtime.

Here's how you enable it project-wide:

using Xamarin.Forms.Xaml;
 
[assembly: XamlCompilation (XamlCompilationOptions.Compile)]
namespace YourApp.Portable
{
    public partial class App
    {
         ...
    }
}


Regards,
Lance | Tech Support Engineer, Sr.
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
tyler
Top achievements
Rank 1
answered on 22 Feb 2018, 08:20 PM
Ok perfect i will use those work arounds.Thank you for the reply
Tags
General Discussions
Asked by
tyler
Top achievements
Rank 1
Answers by
Lance | Manager Technical Support
Telerik team
tyler
Top achievements
Rank 1
Share this question
or