How do I enable text wrapping on all column headers?

Or don’t bother with the primitives in the app.xaml file and do the following (my objects): <DataGrid Name=”WBdataGrid” AutoGenerateColumns=”False” ColumnHeaderHeight=”50″ > <DataGrid.ColumnHeaderStyle> <Style TargetType=”DataGridColumnHeader”> <Setter Property=”ContentTemplate”> <Setter.Value> <DataTemplate> <TextBlock TextWrapping=”Wrap” Text=”{Binding}”></TextBlock> </DataTemplate> </Setter.Value> </Setter> </Style> </DataGrid.ColumnHeaderStyle> <DataGrid.Columns> …

Windows 7 theme for WPF?

WPF comes with the standard Windows themes on all Windows versions. For example, you can have the Aero theme (which Vista and Windows 7 use) on Windows XP with the following steps: Add PresentationFramework.Aero to your application’s references list as a requires Edit your App.xaml from this <Application.Resources> <!– Your stuff here –> </Application.Resources> to … Read more

How to remove DataGrid’s blank row when binding to a ObservableCollection?

The same problem persist in WPF 4.0 version of DataGrid, and it is caused by the add-new row which it shows automatically for ObservableCollection ItemsSource. Setting IsReadOnly as True it’s too radical IMHO. I solved it by disabling CanUserAddRows property if you don’t need that behavior, but you still want cells to be modified: CanUserAddRows=”False”

WPF (MVVM): Closing a view from Viewmodel?

Edit: See my blog post for a more detailed explanation. When I need to achieve that, I use a IRequestCloseViewModel interface that I created. This interface contains only one event: RequestClose. This event is raised by the ViewModel (which inherits from a ViewModelBase class AND implement IRequestCloseViewModel) when it wants to close its associated view. … Read more

Changing the string format of the WPF DatePicker

I have solved this problem with a help of this code. Hope it will help you all as well. <Style TargetType=”{x:Type DatePickerTextBox}”> <Setter Property=”Control.Template”> <Setter.Value> <ControlTemplate> <TextBox x:Name=”PART_TextBox” Text=”{Binding Path=SelectedDate, StringFormat=”dd MMM yyyy”, RelativeSource={RelativeSource AncestorType={x:Type DatePicker}}}” /> </ControlTemplate> </Setter.Value> </Setter> </Style>

Bind datagrid column visibility MVVM

DataGridColumns are not part of visual tree so they are not connected to the data context of the DataGrid. For them to connect together use proxy element approach like this… Add a proxy FrameworkElement in your ancestor panel’s Resources. Host it into an invisible ContentControl bound to its Content. Use this ProxyElement as StaticResource for … Read more

WPF StringFormat on Label Content

The reason this doesn’t work is that the Label.Content property is of type Object, and Binding.StringFormat is only used when binding to a property of type String. What is happening is: The Binding is boxing your MaxLevelOfInvestment value and storing it the Label.Content property as a boxed decimal value. The Label control has a template … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)