1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
| <Window x:Class="WpfApplication3.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WpfApplication3"
Title="MainWindow" Height="350" Width="525">
<Window.DataContext>
<local:VMAllEmployes/>
</Window.DataContext>
<Window.Resources>
<DataTemplate x:Key="HeaderCheckbox" >
<CheckBox
x:Name="chkHeader"
Content="Select All" FontSize="18" Foreground="Red"
IsChecked="{Binding RelativeSource={RelativeSource
Mode=FindAncestor, AncestorType=DataGrid},
Path=DataContext.AllSelectedDays, Mode=TwoWay}" >
</CheckBox>
</DataTemplate >
<DataTemplate x:Key="ItemCheckbox" >
<CheckBox
x:Name="chkItem"
IsChecked="{Binding RelativeSource={RelativeSource
Mode=FindAncestor, AncestorType=DataGrid},
Path=DataContext.AllSelectedDays, Mode=TwoWay}" >
</CheckBox>
</DataTemplate >
<DataTemplate x:Key="ItemCheckboxDay" >
<CheckBox
x:Name="chkItem"
Content="Sel Day"
IsChecked="{Binding Path=IsSelectedDay, Mode=TwoWay}" >
</CheckBox>
</DataTemplate >
</Window.Resources>
<Grid>
<DataGrid
Name="dgEmploye"
Margin="2"
AutoGenerateColumns="False"
CanUserAddRows="False"
SelectionMode="Single"
ItemsSource="{Binding Employes}"
>
<DataGrid.Columns>
<DataGridTemplateColumn
HeaderTemplate="{StaticResource HeaderCheckbox}"
CellTemplate="{StaticResource ItemCheckbox}">
</DataGridTemplateColumn>
<DataGridTextColumn
Header="Employe ID"
Binding="{Binding EmployeID}">
</DataGridTextColumn>
<DataGridTextColumn
Header="VM Info"
Binding="{Binding VM.AllSelectedDays}">
</DataGridTextColumn><DataGridTemplateColumn
Header="Select Day"
CellTemplate="{StaticResource ItemCheckboxDay}">
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
</Grid>
</Window> |
Partager