【问题标题】:C# How to edit Photo & Content place in buttonC#如何在按钮中编辑照片和内容
【发布时间】:2019-04-03 06:54:37
【问题描述】:

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

图片:

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>

【问题讨论】:

    标签: c# wpf xaml button


    【解决方案1】:

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

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

    【讨论】:

    • 很高兴为您提供帮助,欢迎来到 Stack Overflow。如果此答案或任何其他答案解决了您的问题,请将其标记为已接受。
    【解决方案2】:
    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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-09
      • 2017-04-13
      • 2020-09-04
      • 1970-01-01
      • 2017-03-23
      • 1970-01-01
      相关资源
      最近更新 更多