System.Collections.Generic
(1)
System.Windows.Documents
(1)
System.Windows.Controls
(1)
System.Windows.Shapes
(1)
System.Windows.Media
(1)
System.Windows.Input
(1)
ValidationResult
(1)
ValidationRule
(1)

Setting local namespace in xaml file

Asked By DeanB
20-Jun-08 03:52 AM
Please excuse my ignorance here as I have not used WPF for long, but
what is the statement that tells what the "local:" identifier is that
allows a window event to call a function in a .cs file?

Here is the top of a window definition in xaml: I've marked the area
in question with ?????. I have to call the TypeDirectoryValidationRule
function from within the xaml code. I'm also confused on what the

Thanks for any help!.


xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local=???????????????????????????????????????
Title="Type Directory Path" Height="164" Width="566" >
Value="0,3,5,5"></Setter>
Value="0,0,0,5"></Setter>
Value="5,5,5,5"></Setter>
your images:</Label>
local:TypeDirectoryValidationRule>


...

And here is the cs file

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Globalization;
using System.IO;
namespace SlideShowCS
{
/// <summary>
/// Interaction logic for fTypeDirectory.xaml
/// </summary>
public partial class fTypeDirectory : Window
{
public fTypeDirectory()
{
InitializeComponent();
}
}
public class TypeDirectoryValidationRule : ValidationRule
{
public override ValidationResult Validate(object value, CultureInfo
cultureInfo)
{
string sDirName = (string)value;
if (!Directory.Exists(sDirName))
{
string sMsg = string.Format("Directory does not exist: {1}",
sDirName);
return new ValidationResult(false, sMsg);
}
else
{
return new ValidationResult(true, null);
}
}
}
}

Setting local namespace in xaml file

Asked By DeanB
20-Jun-08 03:53 AM
g
I found the answer. FWIW: It was:

xmlns:local=3D"clr-reference.SlideShowCS", where SlideShowCS is the
namespace for the app. I don't know why this is not explained in any
of the books. Anyone know what clr-reference actually is?
Post Question To EggHeadCafe