在这段代码中,我在按钮文本之前添加了一个图像,我希望在图像和文本之间留一个空格,但是我的代码无法正常工作。
<Button Height="25"
Width="80"
Margin="5,10,5,10"
Command="{Binding PreviewTemplateCommand}">
<StackPanel Orientation="Horizontal" Height="15" Width="63">
<Image Source="/UILibrary;component/Themes/Default/Images/preview.PNG"
Height="15" Width="15" Margin="0,0,0,0" />
<TextBlock >Preview</TextBlock>
</StackPanel>
</Button>
最佳答案
嗨,您必须设置文本块的左边距。试试这个:
<StackPanel Orientation="Horizontal" Height="15" Width="63">
<Image Source="..." Height="15" Width="15" Margin="0,0,0,0" />
<TextBlock Margin="25,0,0,0">Preview</TextBlock>
</StackPanel>
关于wpf - 图片和文字之间的边距,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30467938/