【问题标题】:Add image to the radio button将图像添加到单选按钮
【发布时间】:2015-06-22 16:51:46
【问题描述】:
  <StackPanel Name="StpAddDel" Orientation="Horizontal" HorizontalAlignment="Right" Margin="5">
    <RadioButton Name="rdbactive" Content="Active" GroupName="actinact" VerticalAlignment="Center" Margin="5,0" Width="50" Height="15" Foreground="Blue"/>
    <RadioButton Name="rdbinactive" Content="InActive" GroupName="actinact" VerticalAlignment="Center" Margin="5,0" Width="60" Height="15" Foreground="Blue"/>
    <Button Name="BtnAdd"  Height="20" Width="20" Margin="5,0" Template="{StaticResource AddImgBtnTemplate}" />
    <Button Name="BtnDel" Height="20" Width="20" Margin="5,0" Template="{StaticResource DelImgBtnTemplate}" />
  </StackPanel>

这是我的 wpf 窗口中可用的代码。如何将图像添加到 MVVM 中的这些单选按钮。

【问题讨论】:

  • 什么图片?需要绑定什么部分(对于 MVVM)?你这样做有什么问题?你能展示一张你想要它是什么样子的屏幕截图吗?
  • MVVM 与此无关,因为这是 100% 视图相关的。
  • @sparta93 那是 HTML+CSS,这是 WPF 和 XAML
  • 假设例如按钮,我们以同样的方式添加一些图像,我的用户想要向单选按钮添加一些图像
  • @almulo 哎呀,这里是stackoverflow.com/questions/7767667/…

标签: c# wpf xaml


【解决方案1】:

这会将图片添加到单选按钮的背景中。

myRadioButton.Content = new Image()
{
Source = (new ImageSourceConverter()).ConvertFrom(
                         "Images/pic.png") as
                             ImageSource
};

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-08-24
  • 1970-01-01
  • 2014-01-09
相关资源
最近更新 更多