Fish
Fish

Reputation: 165

wpf mahapps theme create items in SplitButton

I'm using wpf mahapps theme and I want to create items for a SplitButton like so:

<Controls:SplitButton HorizontalAlignment="Left" Margin="26,581,0,0" VerticalAlignment="Top" SelectedIndex="1" IsExpanded="True" Background="White">
  <Controls:SplitButton.Items>
          <Button Content="btn" Background="#FFB23E3E"/>
          <MenuItem Background="#FF742323"/>
          <ComboBoxItem Content="cbx" Background="#FFA43131"/>
          <CheckBox Background="#FF8D3535" Content="chk"/>
  </Controls:SplitButton.Items>
</Controls:SplitButton>

but when I click on it, nothing happened and I don't know what's wrong ?

enter image description here

Upvotes: 0

Views: 1103

Answers (1)

Abin
Abin

Reputation: 2956

Try This,

<controls:SplitButton ItemsSource="{Binding}" >
    <controls:SplitButton.ItemTemplate>
        <DataTemplate>
            <Grid>
              <StackPanel>
                <Button Content="btn" Background="#FFB23E3E"/>
                <MenuItem Background="#FF742323"/>
                <ComboBoxItem Content="cbx" Background="#FFA43131"/>
                <CheckBox Background="#FF8D3535" Content="chk"/>
              </StackPanel>
            </Grid>
        </DataTemplate>
    </controls:SplitButton.ItemTemplate>
</controls:SplitButton>

You have to specify ItemSource to populate your ItemTemplate

Upvotes: 1

Related Questions