.NET 4, Caliburn Micro. I need add textBox, comoboBox and some another controls to datagrid headers and bind property from view model class on these controls.
So I try use HeaderTemplate:
XAML:
<DataGrid ItemsSource="{Binding Calls}"
AutoGenerateColumns="False">
<DataGrid.Columns>
<DataGridTextColumn IsReadOnly="True"
CellStyle="{StaticResource CellStyle}"
Binding="{Binding Path=Number}">
<DataGridTextColumn.HeaderTemplate>
<DataTemplate>
<StackPanel Orientation="Vertical">
<TextBlock Text="Cell phone No"/>
<TextBox Width="120"
FontSize="14"
VerticalAlignment="Center"
BorderThickness="1"
Text="{Binding Path=NumberFilterValue,
Mode=OneWayToSource,
UpdateSourceTrigger=PropertyChanged}"/>
</StackPanel>
</DataTemplate>
</DataGridTextColumn.HeaderTemplate>
</DataGridTextColumn>
</DataGrid.Columns>
</DataGrid>
In header I have textBox control and I try bind property NumberFilterValue from view model class.
View model class:
public string NumberFilterValue
{
get { return _numberFilterValue; }
set
{
_numberFilterValue = value;
NotifyOfPropertyChange(() => NumberFilterValue);
FilterCalls();
}
}
Problem is that this binding does not works. Property NumberFilterValue is still empty.
What is root of this problem and how can solve it? Thank you for cooperation.