question

AmitPatel-5670 avatar image
0 Votes"
AmitPatel-5670 asked AmitPatel-5670 answered

Menu Bar in WPF

I want to create a Menu bar in WFP Form, so that I dont write the same code on every page, How can I do that?

windows-wpfdotnet-wpf-xaml
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

DaisyTian-1203 avatar image
0 Votes"
DaisyTian-1203 answered

You can create the Meun Bar in a UserControl, then use it the page which need the Meun Bar.
For example, you can create a UserControl named MyMenuBar like below:

  <DockPanel>
         <Menu DockPanel.Dock="Top">
             <MenuItem Header="_File">
                 <MenuItem Header="_Open"/>
                 <MenuItem Header="_Close"/>
                 <MenuItem Header="_Save"/>
             </MenuItem>
         </Menu>
        <StackPanel></StackPanel>
     </DockPanel>

Then you can use it in Window1 like below:
<local:MyMenuBar></local:MyMenuBar>
The Window1 will show the Meun Bar. Did I misunderstand your question? If I did, could you give me more description of your question for me to anlyze.


If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

AmitPatel-5670 avatar image
0 Votes"
AmitPatel-5670 answered

Thank You @DaisyTian-MSFT , you have understood my query perfectly and has provided the perfect answer.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.