Witam wszytkich,
Korzystam z:
xmlns:ToolKit ="clr-namespace:Xceed.Wpf.Toolkit;assembly=Xceed.Wpf.Toolkit"
W swoim projekcie mam user control który posiada kilkanaście elementów. W dwóch miejscach mam zastasowany masked text box. W jednym miejscu jest w stack panelu i wyglada tak:
<ToolKit:MaskedTextBox Grid.Column="6" x:Name="maskedSessionDuration" Value="{Binding TrainingSessionToAdd.SessionDuration}" ValueDataType="{x:Type System:String}" Mask="0:00" IncludeLiteralsInValue="False" Style="{StaticResource ResourceKey=MaterialDesignTextBox}" TextAlignment="Center" Margin="3">
<i:Interaction.Triggers>
<i:EventTrigger EventName="LostFocus">
<i:InvokeCommandAction Command="{Binding CommandSessionDurationValidation}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</ToolKit:MaskedTextBox>
Praktycznie to samo mam w DataGrid-zie w kolumnie:
<DataGridTemplateColumn Header="Duration" x:Name="columnSessionDuration">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<ToolKit:MaskedTextBox VerticalAlignment="Center" Mask="0:00" Value="{Binding SessionDuration}" ValueDataType="{x:Type System:String}" IncludeLiteralsInValue="False" Background="Transparent" BorderThickness="0" BorderBrush="Transparent" Margin="0 0 0 -2" TextAlignment="Center" Style="{StaticResource ResourceKey=MaterialDesignTextBox}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="LostFocus">
<i:InvokeCommandAction Command="{Binding Source={x:Reference userControlCoordingtorView}, Path=DataContext.CommandChangesessionDuration}" CommandParameter="{Binding RelativeSource={RelativeSource AncestorType={x:Type ToolKit:MaskedTextBox}},Path=Text}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</ToolKit:MaskedTextBox>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
W przypadku pierwsze maskedtextbox, wszystko działa dobrze, w momencie kiedy odpala się command widze, ze binding zadziałał i widze tą wartość, niestety w przypadku maskedtextboxa w DataGrid-zie tak się nie dzieje, property ma wartość null.
Będę wdzięczny na wszelką radę.
Pozdrawiam