I'm making a WPF application on MVVM pattern, where the user clicks the items of a tree (hyperlinks consisting of color names, the name text having the respective foreground) to **change the background of the whole window.** I am doing this through a relay command, but the UI is not acceptable in the View Model, where I am writing the command.

**The tree with Color Names in XAML:**

```
<TreeView Name="tree" ItemSource="{Binding colorList, Mode=TwoWay}" Background="Transparent">
    <TreeView.ItemTemplate>
        <HierarchicalDataTemplate ItemSource={Binding Children}>
             <TextBlock><Hyperlink Command={Binding ColorChangerCommand} Foreground={Binding Foreground} TextDecorations="None"><TextBlock Text={Binding Name}/></Hyperlink></TextBlock>
        </HierarchicalDataTemplate>
     </TreeView.ItemTemplate>
 <TreeView>

```

**The Command in my View Model:**

```
public RelayCommand ColorChangerCommand{ get; set;}

public TreeViewModel() //Constructor of the View Model
{
   ColorChangerCommand= new RelayCommand(ChangeColor);
}

public void ChangeColor(object sender)
{
  this.Background= (sender as TreeViewItem).Foreground;
}

```

The command was working fine in simple code-behind, but now not in the View Model. Help please?