<DataGrid ItemsSource="{Binding Plavkas}" Grid.Row="1" CanUserAddRows="False"
CanUserDeleteRows="False" SelectionMode="Single" SelectedItem="{Binding CurrentPlavka}"
AutoGenerateColumns="False">
<DataGrid.Columns>
<DataGridTextColumn Header="Плавка" Binding="{Binding plavka1}" />
<DataGridComboBoxColumn x:Name="catMetalColumn" Header="Категория" DisplayMemberPath="category" SelectedItemBinding="{Binding catMetal1, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
<DataGridTextColumn x:Name="smenaColumn" Binding="{Binding smena}" Header="Смена"/>
<DataGridTemplateColumn x:Name="dataPrig" Header="Дата приготовление.">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<DatePicker Height="19" FontSize="11" Padding="5,0,0,0" Margin="5,0,5,0"
SelectedDate="{Binding dataPrig, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
Loaded="ComboBox_Loaded"
SelectedDateChanged="DatePicker_SelectedDateChanged"
/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
public class DateToEnabledConverter : IValueConverter {
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
if(value is Plavka)
return ((DateTime.Now - ((Plavkas) value).dataPrig).Days != 1);
return true;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) {
return null;
}
<Window.Resources>
<wpfApplication1:DateToEnabledConverter x:Key="dateToEnabledConverter" />
</Window.Resources>
<DataGridTemplateColumn>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding plavka1}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
<DataGridTemplateColumn.CellEditingTemplate>
<DataTemplate>
<TextBox IsEnabled="{Binding Converter= {StaticResource dateToEnabledConverter}}" Text="{Binding plavka1}" />
</DataTemplate>
</DataGridTemplateColumn.CellEditingTemplate>
</DataGridTemplateColumn>