0

I've added a reference to an app resource in my View's window. But when I declare the resource I get the error:

Error   10  RegexValidationRule is not supported in a Windows Presentation Foundation (WPF) project.

This is how I added the resource to the View:

  <Window.Resources>
        <validators:RegexValidationRule x:Key="localRegexValidationRule"/>
    </Window.Resources>

Does anyone know how to reference the resource correctly in WPF?

I've followed this solution but still get the same error on the resource. This is how I've declared the resource in app.xaml within a resource dictionary:

<Application x:Class="MongoDBApp.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:converters="clr-namespace:MongoDBApp.Converters"
             xmlns:validators="clr-namespace:MongoDBApp.Validators"
             StartupUri="pack://application:,,,/Views/MainView.xaml">
    <Application.Resources>
        <ResourceDictionary>
            <converters:BoolToNonVisibilityConverter x:Key="localBoolToNonVisibilityConverter" />
            <converters:BoolToVisibilityConverter x:Key="localBoolToVisibilityConverter" />
            <validators:RegexValidationRule x:Key="localRegexValidationRule" />
        </ResourceDictionary>
    </Application.Resources>
</Application>
1
  • What about that validator? (validators:RegexValidationRule) Sounds like it is compiled somehow strange. Do you use Blend? ('cause I Googled and found: dotnetgui.blogspot.hu/2012/02/…) Commented Nov 17, 2015 at 21:51

1 Answer 1

1

Have you added the appropriate using statement in your View file? It should have the same statement as your App.xaml file:

         xmlns:validators="clr-namespace:MongoDBApp.Validators"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.