tags:

views:

142

answers:

1

I have in my WPF project file RssInfo.cs in which I have public class

public class DoubleRangeRule : ValidationRule
{
    public double Min { get; set; }
    public double Max { get; set; }

    public override System.Windows.Controls.ValidationResult Validate(object value,
                                               CultureInfo cultureInfo)
    {
       ...
    }
}

and from my XAML code in WPF window class I neet to get to this DoubleRangeRule class..

<!-- reference to my project, all my files are in the WpfCzytanieRSS namespace -->
xmlns:valRule="clr-namespace:WpfCzytanieRSS;assembly=WpfCzytanieRSS" 

<TextBox Validation.ErrorTemplate="{StaticResource TextBoxErrorTemplate}"
         Name="tbTitle">
  <TextBox.Text>
    <Binding Path="Nazwa" UpdateSourceTrigger="PropertyChanged">
      <Binding.ValidationRules>
        <valRule:DoubleRangeRule Min="0.5" Max="10"/> //error place
      </Binding.ValidationRules>
    </Binding>
  </TextBox.Text>
</TextBox>

And i get two errors:

Error 1

The tag 'DoubleRangeRule' does not exist in XML namespace 'clr-namespace:WpfCzytanieRSS;assembly=WpfCzytanieRSS'.

Error 2

The type 'valRule:DoubleRangeRule' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built.

Please help to get to class DoubleRangeRule!

+1  A: 

Is this XAML file in the same project as the DoubleRangeRule? If so, you need to remove the assembly= section from your xmlns declaration. Change it to:

xmlns:valRule="clr-namespace:WpfCzytanieRSS"

If not, then check the namespace that the validation rule class is declared in. For example, if you have placed it in a project subfolder, then Visual Studio by default adds the folder name as a nested namespace e.g. namespace WpfCzytanieRSS.ValidationRules.

itowlson