elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Estamos en la red social de Mastodon


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  .NET (C#, VB.NET, ASP) (Moderador: kub0x)
| | | |-+  Cargar imagen en un botón WPF
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: Cargar imagen en un botón WPF  (Leído 3,403 veces)
Lekim

Desconectado Desconectado

Mensajes: 268



Ver Perfil
Cargar imagen en un botón WPF
« en: 28 Octubre 2015, 20:11 pm »

Hola

Estoy intentando cargar una imagen que tengo en la carpeta Recursos del proyecto en
un  botón. pero no lo consigo porque no se poner la dirección de imagen

He probado esto:
Código
  1.  <Button>
  2. <Image Height="18" Source="/WpfApplication1;component/Resources/Ir.png" Stretch="Fill" Width="18"/>
  3. </Button>

y esto:
Código
  1.  <Button>
  2. <Image Height="18" Source="/Resources/Ir.png" Stretch="Fill" Width="18"/>
  3. </Button>

y esto:
Código
  1.  <Button>
  2. <Image Height="18" Source="Res/Ir.png" Stretch="Fill" Width="18"/>
  3. </Button>


Pero nada no se carga

Gracias


Ya lo he conseguido  :laugh:

Código
  1. <Application x:Class="Application"
  2.    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3.    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4.    StartupUri="MainWindow.xaml">
  5.    <Application.Resources>
  6.        <ImageBrush x:Key="OpenImage">
  7.            <ImageBrush.ImageSource>
  8.                         <BitmapImage UriSource="/Resources/open.png" />
  9.            </ImageBrush.ImageSource>
  10.        </ImageBrush>
  11.  
  12.        <Style TargetType="Button">
  13.            <Setter Property="Background" Value="{StaticResource OpenImage}"/>
  14.        </Style>
  15.  
  16.    </Application.Resources>
  17. </Application>

Una cosa importante. Por defecto la imagen colocada en Resources tiene la propiedad 'Acción de compilación' establecidad en 'Ninguno'. Hay que establecerlo como' Resource'


« Última modificación: 30 Octubre 2015, 13:42 pm por Lekim » En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
cargar aplicacion con boton
Programación Visual Basic
astaroth_15 4 1,841 Último mensaje 10 Abril 2006, 17:14 pm
por Cicklow
CARGAR IMAGEN
Programación Visual Basic
CARRY-ON 2 1,763 Último mensaje 11 Septiembre 2008, 05:52 am
por CARRY-ON
CARGAR UN FORMULARIO PULSANDO UN BOTON « 1 2 »
PHP
bleyarkngel 17 14,111 Último mensaje 30 Junio 2009, 20:42 pm
por [u]nsigned
Cargar imagen en vbs
Scripting
Hekaly 1 3,757 Último mensaje 9 Noviembre 2009, 13:52 pm
por Novlucker
imagen boton
Java
bengy 5 3,150 Último mensaje 7 Septiembre 2012, 03:33 am
por bengy
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines