how to create event handler for dynamic menu in WPF

Hi,

  I am beginner to WPF. I create the menu from database tables using following code....
Now i have struck in, how to call corresponding windows when clicking menu items?
Please its urgent one... help


<Window.Resources>
    <DataTemplate x:Key="navigatetemplate" >
      <TextBlock Text="{Binding menu_name}" ></TextBlock>
    </DataTemplate>
    <HierarchicalDataTemplate x:Key="navmenutemplate" 
       ItemsSource="{Binding ChildRelationship}" 
         ItemTemplate="{StaticResource navigatetemplate}">
      <TextBlock Text="{Binding menu_name}"  Name="txtmenu"> </TextBlock>
    </HierarchicalDataTemplate>
  </Window.Resources>

  <StackPanel>
    <Menu  Name="mymenu" ItemsSource="{Binding dtnavigate}" 
        ItemTemplate="{StaticResource navmenutemplate}"  >
    </Menu>
  </StackPanel>
  private void Window_Loaded(object sender, RoutedEventArgs e)
    {
      mymenu.DataContext = getmenu();
    }
    
    private DataSet getmenu()
    {
      SqlConnection NwindCon = new SqlConnection("server=(local);uid=sa;pwd=zillion;database=ecdslabc20102011");
      SqlDataAdapter navigate = new SqlDataAdapter("select * from navigate order by code ", NwindCon);
      String lc_query = "select n1.code,m.menu_name,m.program from navmenu n1 inner join menu m on n1.menu_code= m.menu_code order by code";
      SqlDataAdapter navmenu = new SqlDataAdapter(lc_query, NwindCon);
      DataSet menudata = new DataSet();
      navigate.Fill(menudata, "dtnavigate");
      navmenu.Fill(menudata, "dtnavmenu");
      DataRelation menurel = new DataRelation("ChildRelationship", menudata.Tables["dtnavigate"].Columns["code"],
         menudata.Tables["dtnavmenu"].Columns["code"], true);
      menurel.Nested = true;
      menudata.Relations.Add(menurel);
       return menudata;
    }

Open in new window

zillion_kameshAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

zillion_kameshAuthor Commented:
Hi,
   ur samples all menu are static.. i created menu based on database values.. then where to put eventhandler?
0
CuteBugCommented:
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
zillion_kameshAuthor Commented:
Thanks for ur solution..  
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.