The statement:
ItemsSource="{Binding Source={StaticResource TTColumn}, Path=Names}" gives the error:
The resource TTColumn could not be resolved.
The entire .xaml code is:
<controls:MetroWindow x:Class="XLTT.Views.RemoveColumn" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls" GlowBrush="{DynamicResource AccentColorBrush}" ShowTitleBar="False" WindowStartupLocation="CenterOwner" ResizeMode="NoResize" WindowStyle="ToolWindow" Height="320" Width="350" Title="Remove Table Column"> <controls:MetroWindow.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" /> <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" /> <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml" /> <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/Blue.xaml" /> <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml" /> <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.AnimatedSingleRowTabControl.xaml" /> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> </controls:MetroWindow.Resources> <Grid Margin="20 10"> <Grid.ColumnDefinitions> <ColumnDefinition/> <ColumnDefinition Width="Auto"/> <ColumnDefinition Width="Auto"/> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> <RowDefinition/> <RowDefinition Height="Auto"/> </Grid.RowDefinitions> <ListBox Margin="5" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" ItemsSource="{Binding Source={StaticResource TTColumn}, Path=Names}" SelectedItem="{Binding SelectedColumn}" Grid.Row="1" BorderBrush="#FFF1F1F1" Background="#FFFFF9F9" Grid.ColumnSpan="3"/> <TextBlock HorizontalAlignment="Stretch" Margin="5 0 5 0" TextWrapping="Wrap" Text="Select Column:" VerticalAlignment="Top" Grid.ColumnSpan="3" FontWeight="Bold" FontFamily="Segoe UI Light" FontSize="24"/> <Button Name="btnOk" Height="30" Content="Remove" HorizontalAlignment="Stretch" Margin="5" VerticalAlignment="Bottom" Width="68" Command="{Binding RemoveColumnCommand}" Grid.Row="2" Grid.Column="1"/> <Button Name="btnCancel" Height="30" Content="Close" HorizontalAlignment="Stretch" Margin="5" VerticalAlignment="Bottom" Width="68" RenderTransformOrigin="1.867,0.75" Click="btnCancel_Click" Grid.Row="2" Grid.Column="2"/> </Grid> </controls:MetroWindow> Here is the definition of the Names variable that I am trying to bind to WPF.
namespace XLTT.Core.Models { public class TTColumn { private static string[] names = {"one", "two", "three"}; // the name field public static string[] Names // the Name property { get { return names; } set { names = value; } } } }