title: Listbox item selection programmatically
body: <p>I have an hamburger Menu with ListBox, When I click on items it is Highlighted and navigated to related page, but when I click on Any link inside the xaml page the hamburger item is not changing even the page is navigated. How to set Listbox item selected and highlighted from code behind.</p>
  
  <p>I am calling the following function from wherever I need to change the Listbox item to my required one</p>
  
  <pre><code>public async static void ChangeSideBarItem()
  {
      ADHome objADHome = new ADHome();
      string selected = App.SelectedPage;
  
      int x = objADHome.SideBarListBox.Items.IndexOf(selected);
      if (!String.IsNullOrEmpty(selected))
      {
          for (int index = 0; index &lt; objADHome.SideBarListBox.Items.Count; index++)
          {
              HamburgerItemClass item = (HamburgerItemClass)objADHome.SideBarListBox.Items[index];
  
              string item1 = item.Title;
              if (selected == item1)
              {
                  objADHome.SideBarListBox.SelectedItem = index;
                  break;
              }
          }
      }
  }
  </code></pre>
  
  <p>I am calling the above method by setting the App.SelectedPage from different xaml page(orders Page) here i have a link Dashboard to navigate back to dashboard page, when i click on that the particular dashboard item in listbox(Sidebar) should be highlighted</p>
  
  <pre><code>private void DashboardLink_Click(object sender, RoutedEventArgs e)
  {
      App.SelectedPage = "Dashboard";
      ADHome.ChangeSideBarItem();
      this.Frame.Navigate(typeof(DashBoard));
  }
  </code></pre>
  
  <p>But its not selected, when I debug it, shows null in selecteditem</p>