C#如何在按钮中编辑照片和内容位置

时间:2019-04-03 06:54:37

标签: c# wpf xaml button

我要插入新按钮 按钮有2个元素的照片和内容 如何在左侧设置照片并在右侧设置内容

图片:

Click Here To Show Image

enter code here
    <Button x:Name="button" Content="New Journaly" HorizontalAlignment="Left" Margin="434,4,0,0" Grid.Row="1" VerticalAlignment="Top" Width="124" RenderTransformOrigin="0.5,0.5" Height="21">
        <Button.Background>
            <ImageBrush ImageSource="/AccMH_V1000;component/Folder/Image/new.png" Stretch="None">
                <ImageBrush.RelativeTransform>
                    <TransformGroup>
                        <ScaleTransform CenterY="0.5" CenterX="0.5"/>
                        <SkewTransform CenterY="0.5" CenterX="0.5"/>
                        <RotateTransform CenterY="0.5" CenterX="0.5"/>
                        <TranslateTransform X="-0.3"/>
                    </TransformGroup>
                </ImageBrush.RelativeTransform>
            </ImageBrush>
        </Button.Background>
    </Button>

2 个答案:

答案 0 :(得分:0)

Button.Content不必为string。相反,您也可以使用StackPanel或任何其他容器:

<Button ...>
    <Button.Content>
        <StackPanel Orientation="Horizontal" ...>
            <Image .../>
            <TextBlock .../>
        </StackPanel>
    </Button.Content>
</Button>

答案 1 :(得分:0)

enter code here
        <Button x:Name="button" Margin="0,0,0.4,0" Grid.Row="1" VerticalAlignment="Top" Height="26" Grid.RowSpan="2" Background="{StaticResource btnStyle}" HorizontalAlignment="Right" Width="69">
            <Button.Content>
                <StackPanel Orientation="Horizontal">
                    <Image Source="/AccMH_V1000;component/Folder/Image/new.png" Height="13" Margin="0,0,10,0"></Image>
                    <TextBlock Name="txt_firstblock" Margin="5,0,0,0" Foreground="White" >  New</TextBlock>
                </StackPanel>
            </Button.Content>
        </Button>

enter image description here