Search Results

Search found 1 results on 1 pages for 'apero'.

Page 1/1 | 1 

  • How can i change background image of a button when hover or click in XAML for Windows 8?

    - by apero
    I got a question about changing the background image of a button when it's clicked. I tried searching on google but i couldn't find something that worked for me. Well here's my code <Button Grid.Column="0" Grid.Row="0" x:Name="btnHome" VerticalAlignment="Stretch" BorderBrush="{x:Null}" HorizontalAlignment="Stretch" Click="btnHome_Click" PointerEntered="btnHome_PointerEntered"> <Button.Template> <ControlTemplate TargetType="Button"> <Border x:Name="RootElement"> <VisualStateManager.VisualStateGroups> <VisualStateGroup x:Name="CommonStates"> <VisualState x:Name="MouseOver"> <Storyboard> //I want my background change here </Storyboard> </VisualState> <VisualState x:Name="Pressed"> <Storyboard> //And here </Storyboard> </VisualState> </VisualStateGroup> </VisualStateManager.VisualStateGroups> <Border.Background> <ImageBrush ImageSource="images/back_button.png"/> </Border.Background> </Border> </ControlTemplate> </Button.Template> </Button> i also tried this private void btnHome_PointerEntered(object sender, PointerRoutedEventArgs e) { BitmapImage bmp = new BitmapImage(); Uri u = new Uri("ms-appx:images/back_button_mouseover.png", UriKind.RelativeOrAbsolute); bmp.UriSource = u; ImageBrush i = new ImageBrush(); i.ImageSource = bmp; btnHome.Background = i; } But unfortunately this worked neither

    Read the article

1