Search code examples
c#wpfxamluser-interfacedevexpress

WPF Button with Image and Text (with the whole button clickable)


I have a button with XAML code with Devexpress as follows:

<dxlc:LayoutItem Width="80" Margin="0,0,0,0">
   <Button Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ob:ViewModel}}, Path=DataContext.ClickCommand}"  ToolTip="CLick this button"
             Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" BorderThickness="1" BorderBrush="DimGray">
     <StackPanel Orientation="Horizontal">
        <Image Source="../../../Resources/Ext/image.png" MaxHeight="16" MinHeight="16" Stretch="Uniform" />
        <dxe:TextEdit EditValue="Click Me" IsReadOnly="True" ShowBorder="False" Foreground="White" Background="Transparent"/>
     </StackPanel>
   </Button>
 </dxlc:LayoutItem>

With this code, only the border of the button is clickable and not the area with the Text. How can I have an image next to a button and have the whole area of the button be clickable?


Solution

  • It seemed like WPF was having some trouble with my TextEdit, so I just changed it to TextBlock and it is now part of the button and clickable.