Doesn't work in a ToolBar

Dec 20, 2009 at 1:58 AM

Hi,

A split button is sorely missing from WPF! Thanks for sharing yours. However, I've found that the control doesn't work in a ToolBar - quite the showstopper for me! You can observe the problem if you alter the Test project to house the button in a ToolBar.

Any ideas?

Dec 20, 2009 at 6:32 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Dec 20, 2009 at 8:41 PM

Hi groky,

Can you paste your XAML code of how you use the split button? When I use this it looks ok:

 

    <Grid>
        <ToolBarTray>
            <ToolBar Height="26"
                     Width="200"
                     Margin="46,0,50,0"
                     Name="toolBar1"
                     VerticalAlignment="Bottom">
                <aea:SplitButton x:Name="Ade"
                                 Click="Ade_Click"
                                 VerticalAlignment="Bottom"
                                 DisplayStyle="TextAndImage"
                                 Width="100"
                                 Height="25"
                                 Source="/AEA.WPFControls.Test;component/Butterfly.jpg"
                                 IsEnabled="True"
                                 IsDropDownOpen="False"
                                 TextImageRelation="ImageBeforeText">
                    <aea:SplitButtonItem IsSelected="True">hello</aea:SplitButtonItem>
                </aea:SplitButton>
                <Separator />
                <Button Content="1455"></Button>
            </ToolBar>
        </ToolBarTray>
    </Grid>

 

    <Grid>

        <ToolBarTray>

            <ToolBar Height="26"

                     Width="200"

                     Margin="46,0,50,0"

                     Name="toolBar1"

                     VerticalAlignment="Bottom">

                <aea:SplitButton x:Name="Ade"

                                 Click="Ade_Click"

                                 VerticalAlignment="Bottom"

                                 DisplayStyle="TextAndImage"

                                 Width="100"

                                 Height="25"

                                 Source="/AEA.WPFControls.Test;component/Butterfly.jpg"

                                 IsEnabled="True"

                                 IsDropDownOpen="False"

                                 TextImageRelation="ImageBeforeText">

                    <aea:SplitButtonItem IsSelected="True">hello</aea:SplitButtonItem>

                </aea:SplitButton>

                <Separator />

                <Button Content="1455"></Button>

            </ToolBar>

        </ToolBarTray>

    </Grid>

 

Regards

 

Ade

 

 

 

Dec 20, 2009 at 9:15 PM
Edited Dec 20, 2009 at 9:20 PM

Hmm yes, your markup does work.

Mine is slightly different in that I don't use a ToolBarTray and don't set the height of the toolbar explicitly:

 

   <Grid>
        <ToolBar>
            <aea:SplitButton x:Name="Ade"
                     Margin="12,12,130,0"
                     SnapsToDevicePixels="False"
                     Click="Ade_Click"
                     Height="42"
                     VerticalAlignment="Top"
                     DisplayStyle="TextAndImage"
                     Source="/AEA.WPFControls.Test;component/Butterfly.jpg"
                     IsEnabled="True"
                     IsDropDownOpen="False"
                     TextImageRelation="ImageBeforeText">
                <aea:SplitButtonItem>SplitButton</aea:SplitButtonItem>
                <aea:SplitButtonItem IsSelected="True">hello</aea:SplitButtonItem>
            </aea:SplitButton>
        </ToolBar>
    </Grid>

The problem seems to arise from the not setting the widths and heights; the control doesn't seem to measure its content correctly. Although I could do this, my toolbar could do with being auto-sizing.

Dec 21, 2009 at 9:57 PM

Hmm yes I see what you mean....I will work on this and get back to you ASAP with a fix.

Sep 26, 2014 at 4:44 AM
Hey, just wanna know how are you doing with this? If you would make the split button something like this it would so great. Keep up the good work!

Cheers,
Ivy
Oct 10, 2014 at 7:54 AM
Hi Ivy,

I couldn't see much from that link, could you explain what you mean?

Thanks