WPF VB.Net

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Resources" Height="300" Width="300"
    >
  
                    ViewportUnits="Absolute" Viewport="0 0 32 32"
                ImageSource="c:\image.jpg">
  

  
    Button
    Change the Brush
  

//File:Window.xaml.vb
Imports System
Imports System.Collections.Generic
Imports System.Text
Imports System.Windows
Imports System.Windows.Controls
Imports System.Windows.Data
Imports System.Windows.Documents
Imports System.Windows.Input
Imports System.Windows.Media
Imports System.Windows.Media.Imaging
Imports System.Windows.Shapes
Namespace Resources
  Public Partial Class DynamicResource
    Inherits System.Windows.Window
    Public Sub New()
      InitializeComponent()
    End Sub
    Private Sub cmdChange_Click(sender As Object, e As RoutedEventArgs)
      Me.Resources("TileBrush") = New SolidColorBrush(Colors.LightBlue)
      Dim brush As ImageBrush = DirectCast(Me.Resources("TileBrush"), ImageBrush)
      brush.Viewport = New Rect(0, 0, 5, 5)
    End Sub
  End Class
End Namespace