How is it possible to make WPF validation work under MAF?

79 views Asked by At

I have a number of WPF executable projects that utilise MVVM. The view models implement INotifyDataErrorInfo. When these WPF apps are run in the standard way validation works as expected - default red border appears and tool tip is updated with error details via a trigger. XAML:

<TextBox Text="{Binding TextBox1Message, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
    <TextBox.Style>
        <Style TargetType="{x:Type TextBox}">
            <Style.Triggers>
                <Trigger Property="Validation.HasError" Value="true">
                    <Setter Property="ToolTip" Value="{Binding RelativeSource={x:Static RelativeSource.Self}, Path=(Validation.Errors)[0].ErrorContent}"/>
                </Trigger>
         </Style.Triggers>
     </Style>
   </TextBox.Style>
</TextBox>

These WPF apps are also add-ins as defined by the MAF architecture (https://msdn.microsoft.com/en-us/library/bb384200(v=vs.110).aspx) and are consumed by a host application. Each add-in provides the host with a contentcontrol which the host displays in its main window. The WPF app continues to work as normal except it is being hosted by a window in another process.

The strange thing about this is that when the app is being hosted, the validation border does not display; however, the tool tip works as expected.

Why does the validation border not work as expected when the WPF app is running in a MAF environment?

0

There are 0 answers