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:
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
add a comment |
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:
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
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
add a comment |
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:
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
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:
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
.net wpf winforms toolstrip toolstripdropdown
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
add a comment |
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
add a comment |
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 MenuItem
s. For example, to have a menu structure like this:
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>
add a comment |
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 MenuItem
s. For example, to have a menu structure like this:
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>
add a comment |
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 MenuItem
s. For example, to have a menu structure like this:
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>
add a comment |
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 MenuItem
s. For example, to have a menu structure like this:
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>
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 MenuItem
s. For example, to have a menu structure like this:
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>
edited Nov 10 at 5:30
answered Sep 17 '17 at 20:04
Reza Aghaei
62.2k850145
62.2k850145
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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