Trying to use a solution for this question gives me a strange problem. (Replicated here for convenience)
This is a solution to the ListView problem by swallowing the right-click event and preventing the AppBar from opening, a class that inherits the ListView and overrides the OnRightTapped ListViewItem event:
public class MyListView : ListView { protected override DependencyObject GetContainerForItemOverride() { return new MyListViewItem(); } } public class MyListViewItem : ListViewItem { protected override void OnRightTapped(Windows.UI.Xaml.Input.RightTappedRoutedEventArgs e) { base.OnRightTapped(e); e.Handled = false;
I implemented a custom control, as indicated, in a new namespace called CustomControls, exactly as described. I added that the namespace in MainPage.xaml
xmlns:CustomControls="using:CustomControls"
When I then try to reference the “ItemsList” in the code behind, I get a compilation error
The name 'ItemsList' does not exist in the current context
I tried building, rebuilding, clearing the solution, closing and reopening the solution, putting the classes in the main project namespace, but to no avail.
To summarize, MainPage.cs does not see the user control on MainPage.xaml
UPDATE 2: Submitted a question to remove irrelevant issues. I also changed the name to reflect the real problem.
source share