Jump to content

Recommended Posts

Posted

criei 2 imagena para o botao, um para quando o cursor estiver em cima outro para quando nao etiver com o curos em cima, o problema eh que eu coloquei um label na frentre, e quando o mouse fica sobre o label, o botao nao altera a imagem, alguem sabe como reolver isso, o projeto é em wpf, xaml,tentei colocar um evento no label para quando o cursor estiver sobre ela, fazer a mudança de imagem do botao, mas nao coneguir xD

aqui ta o codigo do botao para alterar a imagem quando estiver clicado, normal, ou com o cursor em cima

    <Button HorizontalAlignment="Right" Margin="0,229,266,126" Name="button3" Width="350">
	    <Button.Template>
		    <ControlTemplate TargetType="{x:Type Button}">
			    <Grid>
				    <Image Name="Normal" Source="/DartagnanLauncher;component/Images/Untitled-3 copy.png" />
				    <Image Name="MouseOver" Source="/DartagnanLauncher;component/Images/Untitled-4 copy.png" Visibility="Hidden" />
				    <Image Name="Pressed" Source="/DartagnanLauncher;component/Images/Untitled-4 copy.png" Visibility="Hidden" />
				    <Image Name="Disabled" Source="/DartagnanLauncher;component/Images/BT4Start_U2 copy.png" Visibility="Hidden" />
			    </Grid>
			    <ControlTemplate.Triggers>
				    <Trigger Property="ButtonBase.IsPressed" Value="True">
					    <Setter Property="UIElement.Visibility" TargetName="Normal" Value="Hidden" />
					    <Setter Property="UIElement.Visibility" TargetName="Pressed" Value="Visible" />
				    </Trigger>
				    <Trigger Property="UIElement.IsMouseOver" Value="True">
					    <Setter Property="UIElement.Visibility" TargetName="Normal" Value="Hidden" />
					    <Setter Property="UIElement.Visibility" TargetName="MouseOver" Value="Visible" />
				    </Trigger>
				    <Trigger Property="UIElement.IsEnabled" Value="False">
					    <Setter Property="UIElement.Visibility" TargetName="Normal" Value="Hidden" />
					    <Setter Property="UIElement.Visibility" TargetName="Disabled" Value="Visible" />
				    </Trigger>
			    </ControlTemplate.Triggers>
		    </ControlTemplate>
	    </Button.Template>
    </Button>

e aqui o do label

<Label Mouse.MouseEnter="Form1_MouseMove"

e aqui o form1_MouseMove

    void Form1_MouseMove(object sender, MouseEventArgs e) {
	    MessageBox.Show("Mouse no label"); //teste
	    // aqui o metodo para alterar a imagem do botao
    }

entao, nao to coneguindo finalizar o codigo, se alguem souber como ..]

vlw pessoal

  • 2 weeks later...
Posted

Cara, se voce puder me passar esta pagina do seu projeto eu posso te ajudar. Mas somente com o codigo acima esta difícil de visualizar o que está acontecendo.

Fernando Lage Bastos - MCP/MCTS/MCPD

Posted (edited)

Porque razão não tens a label dentro do botão e está em cima do botão?

<Button Style="{StaticResource CellStyle}">
  <TextBlock Text="A" VertialAlignment="Center" />
</Button>

Se fizeres assim, penso que não terás problemas.

Edited by RJ90

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.