What’s wrong with this WP7 Code ?

Here’s a sample code that i was trying for databinding the AutoCompleteBox in Windows Phone 7 .

What’s wrong with this WP7 Code ?

I was trying to bind a custom object to the AutoCompleteBox and ended up looking at the code for nearly 30 mins to figure out why the suggestion was not displaying . It was a simple fix though …

Try finding out the error in the code .

public partial class MainPage : PhoneApplicationPage

{

// Constructor

public MainPage()

{

InitializeComponent();

}

private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)

{

List<Movie> Lst = new List<Movie>();

Lst.Add(new Movie { Name = "Velayutham", Actor = "Vijay" });

Lst.Add(new Movie { Name = "Nanban", Actor = "Vijay" });

Lst.Add(new Movie { Name = "Yohan", Actor = "Vijay" });

Lst.Add(new Movie { Name = "Billa 2", Actor = "Ajith" });

Lst.Add(new Movie { Name = "Maatran", Actor = "Surya" });

autoCompleteBox1.ItemsSource = Lst;

}

}

class Movie

{

public string Name { get; set; }

public string Actor { get; set; }

}

The above code worked fine when i modified the line 21 from

class Movie

{

public string Name { get; set; }

public string Actor { get; set; }

}

to

public class Movie

{

public string Name { get; set; }

public string Actor { get; set; }

}

Just a introduction of the keyword public solved the problem 🙂

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

In this post, you will learn about sync provider notifications in Windows 11 and how to disable or enable it...
In this tutorial, let’s learn how to enable or disable the startup sound in Windows 11. By default, when Windows...
The CameraCaptureTask allows the Windows Phone 7 App to launch the Camera Application . This will be useful when the...