Colors in Visual Studio Extension

Yes, binding to static VS resources is the best approach. It is supported in VS 2012+ and looks like this: <ResourceDictionary xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation” xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml” xmlns:vs_shell=”clr-namespace:Microsoft.VisualStudio.PlatformUI;assembly=Microsoft.VisualStudio.Shell.11.0″> <Style TargetType=”Label”> <Setter Property=”Foreground” Value=”{DynamicResource {x:Static vs_shell:EnvironmentColors.ToolWindowTextBrushKey}}”/> </Style> <Style TargetType=”TextBox”> <Setter Property=”Foreground” Value=”{DynamicResource {x:Static vs_shell:EnvironmentColors.ToolWindowTextBrushKey}}”/> <Setter Property=”Background” Value=”{DynamicResource {x:Static vs_shell:EnvironmentColors.ToolWindowBackgroundBrushKey}}”/> </Style> </ResourceDictionary> See EnvironmentColors Class for all avilable colors.

WPF MenuItem.Command binding to ElementName results to System.Windows.Data Error: 4 : Cannot find source for binding with reference

You can’t bind using element name from a context menu. The link is broken between the context menu and its placement target. You can get around it using a couple of tricks though… Use RoutedUICommands with a command binding on the UserControl, then no binding is needed. Use the placement target binding on the context … Read more

WPF ViewModel Commands CanExecute issue

To complete Will’s answer, here’s a “standard” implementation of the CanExecuteChanged event : public event EventHandler CanExecuteChanged { add { CommandManager.RequerySuggested += value; } remove { CommandManager.RequerySuggested -= value; } } (from Josh Smith’s RelayCommand class) By the way, you should probably consider using RelayCommand or DelegateCommand : you’ll quickly get tired of creating new … Read more

WPF DataGrid : CanContentScroll property causing odd behavior

You are encountering the differences between physical scrolling and logical scrolling. As you have discovered, each has its tradeoffs. Physical scrolling Physical scrolling (CanContentScroll=false) just goes by pixels, so: The viewport always represents exactly the same portion of your scroll extent, giving you a smooth scrolling experience, and but The entire contents of the DataGrid … Read more

ItemsControl ItemTemplate Binding

Are you sure the code you posted here IS the code you use in your solution? Because, this code works for me : XAML <ItemsControl ItemsSource=”{Binding}”> <ItemsControl.ItemTemplate> <DataTemplate> <StackPanel> <TextBlock Text=”{Binding OwnerData.OwnerName}”></TextBlock> <TextBlock Text=”{Binding Credit}” /> </StackPanel> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl> Window’s Loaded Event ObservableCollection<ForDisplay> items = new ObservableCollection<ForDisplay>(); for (int i = 0; i < … Read more