ToolStripDropDownButton equivalent in WPF?









up vote
1
down vote

favorite












I'm very newbie to the WPF technology. I've been developing in WinForms for around 6 years.



Now I would like to advance one big step in my skills by learning WPF. I'm reading the introduction guides in MSDN, while as a personal exercise I'm trying to translate the sructure of a WinForms UI to its WPF UI equivalent.



This is a simple mockup of the WinForms controls structure that I would like to reproduce in WPF:



enter image description here



My problem is trying to reproduce the equivalent control/behavior for the ToolStripDropDownButton control.



In the Windows Forms Controls and Equivalent WPF Controls article, Microsoft just says that the equivalent control for a ToolStripDropDownButton is a ToolBar...with composition. I don't understand at all what it means about "with composition". I've been reading and experimenting with the Toolbar, but I didn't found the way to add a dropdown button thing inside the toolbar.



My question: someone could guide me or show me a brief example of how can I add a drop down button thing inside a Toolbar?.










share|improve this question



















  • 1




    Dropdown Menu in WPF Toolbar?
    – Reza Aghaei
    Sep 16 '17 at 4:25










  • @Reza Aghaei Thanks for comment. My fear is that says it is a "menu", at first sight and talking from my ignorance it seems to be a menu that is shown when the button is clicked, this could mean I will lose/can not reproduce a button control that has by default an arrow drawn at the right of the button? (like in a ToolStripDropDownButton control), I'll try that solution to see if that "menu" at the end can have the expected behavior as a drop down button. Thanks again!
    – ElektroStudios
    Sep 16 '17 at 4:32











  • You're welcome. Based on your question in comments, I added a code sample containing arrow buttons as well as some other controls hosted in sub-menus.
    – Reza Aghaei
    Sep 17 '17 at 20:05














up vote
1
down vote

favorite












I'm very newbie to the WPF technology. I've been developing in WinForms for around 6 years.



Now I would like to advance one big step in my skills by learning WPF. I'm reading the introduction guides in MSDN, while as a personal exercise I'm trying to translate the sructure of a WinForms UI to its WPF UI equivalent.



This is a simple mockup of the WinForms controls structure that I would like to reproduce in WPF:



enter image description here



My problem is trying to reproduce the equivalent control/behavior for the ToolStripDropDownButton control.



In the Windows Forms Controls and Equivalent WPF Controls article, Microsoft just says that the equivalent control for a ToolStripDropDownButton is a ToolBar...with composition. I don't understand at all what it means about "with composition". I've been reading and experimenting with the Toolbar, but I didn't found the way to add a dropdown button thing inside the toolbar.



My question: someone could guide me or show me a brief example of how can I add a drop down button thing inside a Toolbar?.










share|improve this question



















  • 1




    Dropdown Menu in WPF Toolbar?
    – Reza Aghaei
    Sep 16 '17 at 4:25










  • @Reza Aghaei Thanks for comment. My fear is that says it is a "menu", at first sight and talking from my ignorance it seems to be a menu that is shown when the button is clicked, this could mean I will lose/can not reproduce a button control that has by default an arrow drawn at the right of the button? (like in a ToolStripDropDownButton control), I'll try that solution to see if that "menu" at the end can have the expected behavior as a drop down button. Thanks again!
    – ElektroStudios
    Sep 16 '17 at 4:32











  • You're welcome. Based on your question in comments, I added a code sample containing arrow buttons as well as some other controls hosted in sub-menus.
    – Reza Aghaei
    Sep 17 '17 at 20:05












up vote
1
down vote

favorite









up vote
1
down vote

favorite











I'm very newbie to the WPF technology. I've been developing in WinForms for around 6 years.



Now I would like to advance one big step in my skills by learning WPF. I'm reading the introduction guides in MSDN, while as a personal exercise I'm trying to translate the sructure of a WinForms UI to its WPF UI equivalent.



This is a simple mockup of the WinForms controls structure that I would like to reproduce in WPF:



enter image description here



My problem is trying to reproduce the equivalent control/behavior for the ToolStripDropDownButton control.



In the Windows Forms Controls and Equivalent WPF Controls article, Microsoft just says that the equivalent control for a ToolStripDropDownButton is a ToolBar...with composition. I don't understand at all what it means about "with composition". I've been reading and experimenting with the Toolbar, but I didn't found the way to add a dropdown button thing inside the toolbar.



My question: someone could guide me or show me a brief example of how can I add a drop down button thing inside a Toolbar?.










share|improve this question















I'm very newbie to the WPF technology. I've been developing in WinForms for around 6 years.



Now I would like to advance one big step in my skills by learning WPF. I'm reading the introduction guides in MSDN, while as a personal exercise I'm trying to translate the sructure of a WinForms UI to its WPF UI equivalent.



This is a simple mockup of the WinForms controls structure that I would like to reproduce in WPF:



enter image description here



My problem is trying to reproduce the equivalent control/behavior for the ToolStripDropDownButton control.



In the Windows Forms Controls and Equivalent WPF Controls article, Microsoft just says that the equivalent control for a ToolStripDropDownButton is a ToolBar...with composition. I don't understand at all what it means about "with composition". I've been reading and experimenting with the Toolbar, but I didn't found the way to add a dropdown button thing inside the toolbar.



My question: someone could guide me or show me a brief example of how can I add a drop down button thing inside a Toolbar?.







.net wpf winforms toolstrip toolstripdropdown






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Oct 29 '17 at 7:28









Reza Aghaei

62.2k850145




62.2k850145










asked Sep 16 '17 at 4:23









ElektroStudios

7,68223110274




7,68223110274







  • 1




    Dropdown Menu in WPF Toolbar?
    – Reza Aghaei
    Sep 16 '17 at 4:25










  • @Reza Aghaei Thanks for comment. My fear is that says it is a "menu", at first sight and talking from my ignorance it seems to be a menu that is shown when the button is clicked, this could mean I will lose/can not reproduce a button control that has by default an arrow drawn at the right of the button? (like in a ToolStripDropDownButton control), I'll try that solution to see if that "menu" at the end can have the expected behavior as a drop down button. Thanks again!
    – ElektroStudios
    Sep 16 '17 at 4:32











  • You're welcome. Based on your question in comments, I added a code sample containing arrow buttons as well as some other controls hosted in sub-menus.
    – Reza Aghaei
    Sep 17 '17 at 20:05












  • 1




    Dropdown Menu in WPF Toolbar?
    – Reza Aghaei
    Sep 16 '17 at 4:25










  • @Reza Aghaei Thanks for comment. My fear is that says it is a "menu", at first sight and talking from my ignorance it seems to be a menu that is shown when the button is clicked, this could mean I will lose/can not reproduce a button control that has by default an arrow drawn at the right of the button? (like in a ToolStripDropDownButton control), I'll try that solution to see if that "menu" at the end can have the expected behavior as a drop down button. Thanks again!
    – ElektroStudios
    Sep 16 '17 at 4:32











  • You're welcome. Based on your question in comments, I added a code sample containing arrow buttons as well as some other controls hosted in sub-menus.
    – Reza Aghaei
    Sep 17 '17 at 20:05







1




1




Dropdown Menu in WPF Toolbar?
– Reza Aghaei
Sep 16 '17 at 4:25




Dropdown Menu in WPF Toolbar?
– Reza Aghaei
Sep 16 '17 at 4:25












@Reza Aghaei Thanks for comment. My fear is that says it is a "menu", at first sight and talking from my ignorance it seems to be a menu that is shown when the button is clicked, this could mean I will lose/can not reproduce a button control that has by default an arrow drawn at the right of the button? (like in a ToolStripDropDownButton control), I'll try that solution to see if that "menu" at the end can have the expected behavior as a drop down button. Thanks again!
– ElektroStudios
Sep 16 '17 at 4:32





@Reza Aghaei Thanks for comment. My fear is that says it is a "menu", at first sight and talking from my ignorance it seems to be a menu that is shown when the button is clicked, this could mean I will lose/can not reproduce a button control that has by default an arrow drawn at the right of the button? (like in a ToolStripDropDownButton control), I'll try that solution to see if that "menu" at the end can have the expected behavior as a drop down button. Thanks again!
– ElektroStudios
Sep 16 '17 at 4:32













You're welcome. Based on your question in comments, I added a code sample containing arrow buttons as well as some other controls hosted in sub-menus.
– Reza Aghaei
Sep 17 '17 at 20:05




You're welcome. Based on your question in comments, I added a code sample containing arrow buttons as well as some other controls hosted in sub-menus.
– Reza Aghaei
Sep 17 '17 at 20:05












1 Answer
1






active

oldest

votes

















up vote
2
down vote



accepted










You can put a Menu in Toolbar. A Menu contains some MenuItem. Each MenuItem has a Header which is it's content and can be a text or other elements. Also each MenuItem can have some nested or MenuItems. For example, to have a menu structure like this:



enter image description here



You can use such code:



<ToolBar>
<Menu Background="#00000000">
<MenuItem >
<MenuItem.Header>
<StackPanel Orientation="Horizontal">
<TextBlock>Menu 1</TextBlock>
<Path VerticalAlignment="Center" Margin="8,2,0,0"
Fill="Black" Data="M 0 0 L 3 3 L 6 0 Z"/>
</StackPanel>
</MenuItem.Header>
<MenuItem Header="Menu 1-1" >
<MenuItem Header="Menu 1-1-1"/>
<MenuItem Header="Menu 1-1-2"/>
</MenuItem>
<MenuItem Header="Menu 1-2"/>
<MenuItem>
<MenuItem.Header><TextBox Width="100"/></MenuItem.Header>
</MenuItem>
<MenuItem>
<MenuItem.Header><DatePicker Width="100"/></MenuItem.Header>
</MenuItem>
</MenuItem>
<MenuItem >
<MenuItem.Header>
<StackPanel Orientation="Horizontal">
<TextBlock>Menu 2</TextBlock>
<Path VerticalAlignment="Center" Margin="8,2,0,0"
Fill="Black" Data="M 0 0 L 3 3 L 6 0 Z"/>
</StackPanel>
</MenuItem.Header>
<MenuItem Header="Menu 2-1"/>
<MenuItem Header="Menu 2-2"/>
<MenuItem Header="Menu 2-3"/>
</MenuItem>
<MenuItem Header="Menu 3"/>
</Menu>
</ToolBar>





share|improve this answer






















    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f46250026%2ftoolstripdropdownbutton-equivalent-in-wpf%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    2
    down vote



    accepted










    You can put a Menu in Toolbar. A Menu contains some MenuItem. Each MenuItem has a Header which is it's content and can be a text or other elements. Also each MenuItem can have some nested or MenuItems. For example, to have a menu structure like this:



    enter image description here



    You can use such code:



    <ToolBar>
    <Menu Background="#00000000">
    <MenuItem >
    <MenuItem.Header>
    <StackPanel Orientation="Horizontal">
    <TextBlock>Menu 1</TextBlock>
    <Path VerticalAlignment="Center" Margin="8,2,0,0"
    Fill="Black" Data="M 0 0 L 3 3 L 6 0 Z"/>
    </StackPanel>
    </MenuItem.Header>
    <MenuItem Header="Menu 1-1" >
    <MenuItem Header="Menu 1-1-1"/>
    <MenuItem Header="Menu 1-1-2"/>
    </MenuItem>
    <MenuItem Header="Menu 1-2"/>
    <MenuItem>
    <MenuItem.Header><TextBox Width="100"/></MenuItem.Header>
    </MenuItem>
    <MenuItem>
    <MenuItem.Header><DatePicker Width="100"/></MenuItem.Header>
    </MenuItem>
    </MenuItem>
    <MenuItem >
    <MenuItem.Header>
    <StackPanel Orientation="Horizontal">
    <TextBlock>Menu 2</TextBlock>
    <Path VerticalAlignment="Center" Margin="8,2,0,0"
    Fill="Black" Data="M 0 0 L 3 3 L 6 0 Z"/>
    </StackPanel>
    </MenuItem.Header>
    <MenuItem Header="Menu 2-1"/>
    <MenuItem Header="Menu 2-2"/>
    <MenuItem Header="Menu 2-3"/>
    </MenuItem>
    <MenuItem Header="Menu 3"/>
    </Menu>
    </ToolBar>





    share|improve this answer


























      up vote
      2
      down vote



      accepted










      You can put a Menu in Toolbar. A Menu contains some MenuItem. Each MenuItem has a Header which is it's content and can be a text or other elements. Also each MenuItem can have some nested or MenuItems. For example, to have a menu structure like this:



      enter image description here



      You can use such code:



      <ToolBar>
      <Menu Background="#00000000">
      <MenuItem >
      <MenuItem.Header>
      <StackPanel Orientation="Horizontal">
      <TextBlock>Menu 1</TextBlock>
      <Path VerticalAlignment="Center" Margin="8,2,0,0"
      Fill="Black" Data="M 0 0 L 3 3 L 6 0 Z"/>
      </StackPanel>
      </MenuItem.Header>
      <MenuItem Header="Menu 1-1" >
      <MenuItem Header="Menu 1-1-1"/>
      <MenuItem Header="Menu 1-1-2"/>
      </MenuItem>
      <MenuItem Header="Menu 1-2"/>
      <MenuItem>
      <MenuItem.Header><TextBox Width="100"/></MenuItem.Header>
      </MenuItem>
      <MenuItem>
      <MenuItem.Header><DatePicker Width="100"/></MenuItem.Header>
      </MenuItem>
      </MenuItem>
      <MenuItem >
      <MenuItem.Header>
      <StackPanel Orientation="Horizontal">
      <TextBlock>Menu 2</TextBlock>
      <Path VerticalAlignment="Center" Margin="8,2,0,0"
      Fill="Black" Data="M 0 0 L 3 3 L 6 0 Z"/>
      </StackPanel>
      </MenuItem.Header>
      <MenuItem Header="Menu 2-1"/>
      <MenuItem Header="Menu 2-2"/>
      <MenuItem Header="Menu 2-3"/>
      </MenuItem>
      <MenuItem Header="Menu 3"/>
      </Menu>
      </ToolBar>





      share|improve this answer
























        up vote
        2
        down vote



        accepted







        up vote
        2
        down vote



        accepted






        You can put a Menu in Toolbar. A Menu contains some MenuItem. Each MenuItem has a Header which is it's content and can be a text or other elements. Also each MenuItem can have some nested or MenuItems. For example, to have a menu structure like this:



        enter image description here



        You can use such code:



        <ToolBar>
        <Menu Background="#00000000">
        <MenuItem >
        <MenuItem.Header>
        <StackPanel Orientation="Horizontal">
        <TextBlock>Menu 1</TextBlock>
        <Path VerticalAlignment="Center" Margin="8,2,0,0"
        Fill="Black" Data="M 0 0 L 3 3 L 6 0 Z"/>
        </StackPanel>
        </MenuItem.Header>
        <MenuItem Header="Menu 1-1" >
        <MenuItem Header="Menu 1-1-1"/>
        <MenuItem Header="Menu 1-1-2"/>
        </MenuItem>
        <MenuItem Header="Menu 1-2"/>
        <MenuItem>
        <MenuItem.Header><TextBox Width="100"/></MenuItem.Header>
        </MenuItem>
        <MenuItem>
        <MenuItem.Header><DatePicker Width="100"/></MenuItem.Header>
        </MenuItem>
        </MenuItem>
        <MenuItem >
        <MenuItem.Header>
        <StackPanel Orientation="Horizontal">
        <TextBlock>Menu 2</TextBlock>
        <Path VerticalAlignment="Center" Margin="8,2,0,0"
        Fill="Black" Data="M 0 0 L 3 3 L 6 0 Z"/>
        </StackPanel>
        </MenuItem.Header>
        <MenuItem Header="Menu 2-1"/>
        <MenuItem Header="Menu 2-2"/>
        <MenuItem Header="Menu 2-3"/>
        </MenuItem>
        <MenuItem Header="Menu 3"/>
        </Menu>
        </ToolBar>





        share|improve this answer














        You can put a Menu in Toolbar. A Menu contains some MenuItem. Each MenuItem has a Header which is it's content and can be a text or other elements. Also each MenuItem can have some nested or MenuItems. For example, to have a menu structure like this:



        enter image description here



        You can use such code:



        <ToolBar>
        <Menu Background="#00000000">
        <MenuItem >
        <MenuItem.Header>
        <StackPanel Orientation="Horizontal">
        <TextBlock>Menu 1</TextBlock>
        <Path VerticalAlignment="Center" Margin="8,2,0,0"
        Fill="Black" Data="M 0 0 L 3 3 L 6 0 Z"/>
        </StackPanel>
        </MenuItem.Header>
        <MenuItem Header="Menu 1-1" >
        <MenuItem Header="Menu 1-1-1"/>
        <MenuItem Header="Menu 1-1-2"/>
        </MenuItem>
        <MenuItem Header="Menu 1-2"/>
        <MenuItem>
        <MenuItem.Header><TextBox Width="100"/></MenuItem.Header>
        </MenuItem>
        <MenuItem>
        <MenuItem.Header><DatePicker Width="100"/></MenuItem.Header>
        </MenuItem>
        </MenuItem>
        <MenuItem >
        <MenuItem.Header>
        <StackPanel Orientation="Horizontal">
        <TextBlock>Menu 2</TextBlock>
        <Path VerticalAlignment="Center" Margin="8,2,0,0"
        Fill="Black" Data="M 0 0 L 3 3 L 6 0 Z"/>
        </StackPanel>
        </MenuItem.Header>
        <MenuItem Header="Menu 2-1"/>
        <MenuItem Header="Menu 2-2"/>
        <MenuItem Header="Menu 2-3"/>
        </MenuItem>
        <MenuItem Header="Menu 3"/>
        </Menu>
        </ToolBar>






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 10 at 5:30

























        answered Sep 17 '17 at 20:04









        Reza Aghaei

        62.2k850145




        62.2k850145



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f46250026%2ftoolstripdropdownbutton-equivalent-in-wpf%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Use pre created SQLite database for Android project in kotlin

            Darth Vader #20

            Ondo