Search code examples
wpfxaml

How do I set the text on a button in WPF?


I'm making a basic button in WPF, as so:

<Grid >

        <TextBox HorizontalAlignment="Left" Height="23" Margin="23,10,0,0" Text="{Binding Path=EnteredPassword}" TextWrapping="Wrap"  VerticalAlignment="Top" Width="120" TextChanged="TextBox_TextChanged"/>
        <Button Content="Button"  Command="{Binding AddMasterPasswordCommand}" HorizontalAlignment="Left" Margin="162,10,0,0" VerticalAlignment="Top" Width="75" Click="Button_Click">
            <TextBlock>Set Master Password</TextBlock>
        </Button>

    </Grid>

As such, I get the dreaded 'The property content is set more than once error' It seems like I should be able to plop a textblock on a button like that. Are there other ways to insert text on a button? Say I want to add "press me" to the button.


Solution

  • What happens if you remove the TextBlock and you set the Content attribute in the button to be Set Master Password?