到目前为止,我需要将自定义图片而不是SymbolIcon设置为RadioButton Tag
属性:
Home.Tag = new BitmapImage(new Uri("ms-appx:///Assets/my_asset.png"));
Home
是我的无线电按钮的名称;
不要工作,有人可以帮忙吗?
答案 0 :(得分:0)
试试这个
var b = new BitmapImage();
b.BeginInit();
b.UriSource = new Uri(@"ms-appx:///Assets/my_asset.png", UriKind.RelativeOrAbsolute);
b.EndInit();
Home.Tag = b;
答案 1 :(得分:0)
要在单选按钮中设置图像而不是使用内容标记设置XAML,如下所示: -
<StackPanel x:Name="rbMode2" Orientation="Horizontal" HorizontalAlignment="Center" Margin="5" Visibility="Collapsed">
<RadioButton x:Name="rbDrive1" Tag="Drive" IsChecked="true" Margin="5,0,0,0"
GroupName="ShowSaveRoute" Tapped="RadioRouteMode_Tapped">
<StackPanel>
<Image Source="ms-appx:///images/Car.png" />
</StackPanel>
</RadioButton>
<RadioButton x:Name="rbWalk1" Tag="Walk" Margin="5,0,0,0"
GroupName="ShowSaveRoute" Tapped="RadioRouteMode_Tapped">
<StackPanel>
<Image Source="ms-appx:///images/Walking.png" />
</StackPanel>
</RadioButton>
<RadioButton x:Name="rbFly1" Tag="Fly" Margin="5,0,0,0"
GroupName="ShowSaveRoute" Tapped="RadioRouteMode_Tapped">
<StackPanel>
<Image Source="ms-appx:///images/Airplane.png" />
</StackPanel>
</RadioButton>
</StackPanel>
项目图像文件夹中保存的图像