Witam
Próbuje zmienić tło siatki ale nie wiem jak mam się do niego dostać z poziomu kodu C#.
Chcę by po naciśnięciu siatki, obraz się zmienił.
Kod XAML:
<Window x:Class="GhostApp1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:GhostApp1"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
<Grid x:Name="Tło">
<Grid.Background>
<ImageBrush ImageSource="C:\Users\Karol\Desktop\Projekt\next.jpg"/> // Jak do tego się dostać ??
</Grid.Background>
<Button x:Name="Test" Content="Zmiana" HorizontalAlignment="Left" Margin="224,191,0,0" VerticalAlignment="Top" Width="75" RenderTransformOrigin="-0.493,0.367" Click="Test_Click"/>
<Image x:Name="image" HorizontalAlignment="Left" Height="319" VerticalAlignment="Top" Width="517">
<Image.OpacityMask>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="Black" Offset="0"/>
<GradientStop Color="#FF911D1D" Offset="1"/>
</LinearGradientBrush>
</Image.OpacityMask>
</Image>
</Grid>
</Window>
Kod C#:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Effects;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace GhostApp1
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void Test_Click(object sender, RoutedEventArgs e)
{
}
}
}