Validation of create user form in Silverlight - silverlight

I am making a Silverlight 4.0 Navigation Application with Authentication Service to manage users, log in/out and so forth.
I have used the msdn tutorial on this page: http://msdn.microsoft.com/en-us/library/ee942451%28v=vs.91%29.aspx
It works great. I can create users with some custom profile properties and log in and out.
The problem is my create user form. As in the tutorial I have in my service project made a class called NewUser, with data annotations. These seems to work, as if I try to create a user with a invalid field, the creation fails, and i get an exception, with the message that there are validation errors.
I would like this validation to work with my form. In other forms I just bind an instance of a class to the form and set the binding for each field with validationOnException to true and notifyOnValidationError to true.
I have made the bindings in the create user form as in my other forms, but they do not seem to work. I have tried to set a breakpoint in a set of a property on the NewUser class. It looks like it do not get called/used at all.
This is most likely a simple matter of me missing something, but I can not found out what. Does it have anything to do with the fact that the NewUser class is in my service project and the form is in the client project. I hope you guys can help me.
My code for the NewUser class
public class NewUser
{
private string username;
[Key]
[Required()]
public string UserName { get; set; }
[Key]
[Required()]
[RegularExpression(#"^([\w-\.]+)#((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$", ErrorMessage="Invalid email. An email must use the format username#mycompany.com")]
public string Email { get; set; }
[Required()]
public string Firstname { get; set; }
[Required()]
public string Lastname { get; set; }
[Required()]
public DateTime Birthsday { get; set; }
[Required()]
public bool SentNewsletter { get; set; }
[Required()]
public bool SentReminders { get; set; }
[Required()]
public string Password { get; set; }
[CustomValidation(typeof(RegistrationValidator), "IsPasswordConfirmed")]
public string ConfirmPassword { get; set; }
[Required()]
public string SecurityQuestion { get; set; }
[Required()]
public string SecurityAnswer { get; set; }
}
My create user form xaml
<navigation:Page x:Class="OenskePortalen.Views.Pages.CreateNewUser"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
xmlns:input="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data.Input"
xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
xmlns:uc="clr-namespace:OenskePortalen.Views.Controls"
d:DesignWidth="640" d:DesignHeight="680"
Title="CreateNewUser Page">
<Grid x:Name="LayoutRoot" Background="White">
<Grid.RowDefinitions>
<RowDefinition Height="50" />
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="180"/>
<ColumnDefinition Width="10"/>
<ColumnDefinition Width="160"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<uc:InfoBox Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="4" DisplayText="Her kan du oprette dig som bruger på ØnskePortalen" VerticalAlignment="Top"/>
<TextBlock Grid.Row="1" Grid.Column="0" Text="Brugernavn" VerticalAlignment="Center"/>
<TextBlock Grid.Row="1" Grid.Column="1" Text=":" VerticalAlignment="Center"/>
<TextBox Grid.Row="1" Grid.Column="2" x:Name="txtUsername" Text="{Binding UserName, Mode=TwoWay, ValidatesOnExceptions=True, NotifyOnValidationError=True}" VerticalAlignment="Center" Width="150" Margin="5" HorizontalAlignment="Left" />
<TextBlock Grid.Row="2" Grid.Column="0" Text="Fornavn" VerticalAlignment="Center"/>
<TextBlock Grid.Row="2" Grid.Column="1" Text=":" VerticalAlignment="Center"/>
<TextBox Grid.Row="2" Grid.Column="2" x:Name="txtFirstname" Text="{Binding Firstname, Mode=TwoWay, ValidatesOnExceptions=True, NotifyOnValidationError=True}" VerticalAlignment="Center" Width="150" Margin="5" HorizontalAlignment="Left" />
<TextBlock Grid.Row="3" Grid.Column="0" Text="Efternavn" VerticalAlignment="Center"/>
<TextBlock Grid.Row="3" Grid.Column="1" Text=":" VerticalAlignment="Center"/>
<TextBox Grid.Row="3" Grid.Column="2" x:Name="txtLastname" Text="{Binding Lastname, Mode=TwoWay, ValidatesOnExceptions=True, NotifyOnValidationError=True}" VerticalAlignment="Center" Width="150" Margin="5" HorizontalAlignment="Left" />
<TextBlock Grid.Row="4" Grid.Column="0" Text="Email" VerticalAlignment="Center"/>
<TextBlock Grid.Row="4" Grid.Column="1" Text=":" VerticalAlignment="Center"/>
<TextBox Grid.Row="4" Grid.Column="2" x:Name="txtEmail" Text="{Binding Email, Mode=TwoWay, ValidatesOnExceptions=True, NotifyOnValidationError=True}" VerticalAlignment="Center" Width="150" Margin="5" HorizontalAlignment="Left" />
<TextBlock Grid.Row="5" Grid.Column="0" Text="Adgangskode" VerticalAlignment="Center"/>
<TextBlock Grid.Row="5" Grid.Column="1" Text=":" VerticalAlignment="Center"/>
<PasswordBox Grid.Row="5" Grid.Column="2" x:Name="txtPassword" Password="{Binding Password, Mode=TwoWay, ValidatesOnExceptions=True, NotifyOnValidationError=True}" VerticalAlignment="Center" Width="150" Margin="5" />
<TextBlock Grid.Row="6" Grid.Column="0" Text="Gentag adgangskode" VerticalAlignment="Center"/>
<TextBlock Grid.Row="6" Grid.Column="1" Text=":" VerticalAlignment="Center"/>
<PasswordBox Grid.Row="6" Grid.Column="2" x:Name="txtPasswordRepeat" Password="{Binding PasswordConfirm, Mode=TwoWay, ValidatesOnExceptions=True, NotifyOnValidationError=True}" VerticalAlignment="Center" Width="150" Margin="5" />
<TextBlock Grid.Row="7" Grid.Column="0" Text="Sikkerhedsspørgsmål" VerticalAlignment="Center"/>
<TextBlock Grid.Row="7" Grid.Column="1" Text=":" VerticalAlignment="Center"/>
<TextBox Grid.Row="7" Grid.Column="2" x:Name="txtPasswordQuestion" Text="{Binding SecurityQuestion, Mode=TwoWay, ValidatesOnExceptions=True, NotifyOnValidationError=True}" VerticalAlignment="Center" Width="150" Margin="5" HorizontalAlignment="Left" />
<TextBlock Grid.Row="8" Grid.Column="0" Text="Sikkerhedssvar" VerticalAlignment="Center"/>
<TextBlock Grid.Row="8" Grid.Column="1" Text=":" VerticalAlignment="Center"/>
<TextBox Grid.Row="8" Grid.Column="2" x:Name="txtPasswordAnswer" Text="{Binding SecurityAnswer, Mode=TwoWay, ValidatesOnExceptions=True, NotifyOnValidationError=True}" VerticalAlignment="Center" Width="150" Margin="5" HorizontalAlignment="Left" />
<TextBlock Grid.Row="9" Grid.Column="0" Text="Fødselsdag" VerticalAlignment="Center"/>
<TextBlock Grid.Row="9" Grid.Column="1" Text=":" VerticalAlignment="Center"/>
<sdk:DatePicker Grid.Row="9" Grid.Column="2" x:Name="dpBirthsday" SelectedDate="{Binding Birthsday, Mode=TwoWay, ValidatesOnExceptions=True, NotifyOnValidationError=True}" VerticalAlignment="Center" Width="150" Margin="5" HorizontalAlignment="Left"/>
<TextBlock Grid.Row="10" Grid.Column="0" Text="Nyhedsbrev" VerticalAlignment="Center"/>
<TextBlock Grid.Row="10" Grid.Column="1" Text=":" VerticalAlignment="Center"/>
<CheckBox Grid.Row="10" Grid.Column="2" x:Name="cboxNewsletter" IsChecked="{Binding SentNewsletter, Mode=TwoWay, ValidatesOnExceptions=True, NotifyOnValidationError=True}" VerticalAlignment="Center" Margin="5"/>
<TextBlock Grid.Row="11" Grid.Column="0" Text="Påmindelser om fødselsdage" VerticalAlignment="Center"/>
<TextBlock Grid.Row="11" Grid.Column="1" Text=":" VerticalAlignment="Center" />
<CheckBox Grid.Row="11" Grid.Column="2" x:Name="cboxReminders" IsChecked="{Binding SentReminders, Mode=TwoWay, ValidatesOnExceptions=True, NotifyOnValidationError=True}" VerticalAlignment="Center" Margin="5"/>
<StackPanel Grid.Row="12" Grid.Column="0" Grid.ColumnSpan="3" HorizontalAlignment="Right" Orientation="Horizontal" >
<Button x:Name="btnCreate" Style="{StaticResource GreenButton}" Background="{StaticResource GreenGradientBrush}" Height="20" Margin="5" Click="btnCreate_Click" Cursor="Hand" >
<TextBlock Text="Opret ny bruger" Style="{StaticResource textStyleBlack}" />
</Button>
<Button x:Name="btnCancel" Style="{StaticResource BlueButton}" Background="{StaticResource BlueGradientBrush}" Height="20" Margin="5" Click="btnCancel_Click" Cursor="Hand" >
<TextBlock Text="Annuller" Style="{StaticResource textStyleBlack}" />
</Button>
</StackPanel>
<input:ValidationSummary Grid.Row="13" Grid.Column="0" Grid.ColumnSpan="3" />
</Grid>
And my create user form code behind
public partial class CreateNewUser : Page
{
private NewUser user;
public CreateNewUser()
{
InitializeComponent();
user = new NewUser();
LayoutRoot.DataContext = user;
dpBirthsday.SelectedDate = DateTime.Now;
cboxNewsletter.IsChecked = true;
cboxReminders.IsChecked = true;
}
private void btnCreate_Click(object sender, RoutedEventArgs e)
{
updateValidation();
if (!Validation.GetHasError(LayoutRoot))
{
RegistrationDomainContext context = new RegistrationDomainContext();
NewUser user = new NewUser();
try
{
user.UserName = txtUsername.Text;
user.Password = txtPassword.Password;
user.Email = txtEmail.Text;
user.ConfirmPassword = txtPassword.Password;
user.SecurityQuestion = txtPasswordQuestion.Text;
user.SecurityAnswer = txtPasswordAnswer.Text;
user.Firstname = txtFirstname.Text;
user.Lastname = txtLastname.Text;
user.Birthsday = dpBirthsday.SelectedDate.GetValueOrDefault(DateTime.Now);
user.SentNewsletter = cboxNewsletter.IsChecked.GetValueOrDefault(true);
user.SentReminders = cboxReminders.IsChecked.GetValueOrDefault(true);
context.NewUsers.Add(user);
context.SubmitChanges(RegisterUser_Completed, null);
}
catch (Exception exc)
{
ErrorWindow w = new ErrorWindow(exc);
w.Show();
}
} // end validation
}
private void RegisterUser_Completed(SubmitOperation so)
{
if (so.HasError)
{
ErrorWindow ew = new ErrorWindow(so.Error);
ew.Show();
so.MarkErrorAsHandled();
}
else
{
LoginParameters lp = new LoginParameters(txtUsername.Text, txtPassword.Password);
}
}
private void btnCancel_Click(object sender, RoutedEventArgs e)
{
MainPage mp = Application.Current.RootVisual as MainPage;
mp.contentFrame.Navigate(new Uri("/home", UriKind.Relative));
}
private void updateValidation()
{
foreach (var current in LayoutRoot.Children)
{
if (current is TextBox)
(current as TextBox).GetBindingExpression(TextBox.TextProperty).UpdateSource();
if (current is PasswordBox)
(current as PasswordBox).GetBindingExpression(PasswordBox.PasswordProperty).UpdateSource();
}
}
}

I believe that you can't databind to a private field - try changing user in your code-behind to a public property (and maybe look at implementing INotifyPropertyChanged).

Related

WPF Prism EventAggregator subscriber does not get the published event

I am trying to implement Prism EventAggregator in building an App using Prism.
My design is as below:
Publisher VM class
class MainViewModel : INotifyPropertyChanged
{
private LADataService lADataService;
LADataService sa = new LADataService();
public List<LAInfo> LADetails
{
get
{
return this._laDetails;
}
set
{
if (this._laDetails != value)
{
this._laDetails = value;
this.NotifyPropertyChanged("LADetails");
}
}
}
public LAInfo SelectedLA
{
get
{
return _selectedla;
}
set
{
if (_selectedla != value)
{
_selectedla = value;
NotifyPropertyChanged("SelectedLA");
//NavigationParameters navParameter = new NavigationParameters();
//navParameter.Add("SelectedLA", SelectedLA);
// Publish event.
iEventAggregator
.GetEvent<PubSubEvent<LAInfo>>()
.Publish(this.SelectedLA);
}
}
}
Subscriber VM
class PopUpFormViewModel : INotifyPropertyChanged, INavigationAware
{
private LAInfo _lainfo;
public LAInfo LAInfo
{
get
{
return this._lainfo;
}
set
{
if (this._lainfo != value)
{
this._lainfo = value;
this.NotifyPropertyChanged("LAInfo");
}
}
}
public PopUpFormViewModel(IEventAggregator iEventAggregator)
{
this.iEventAggregator = iEventAggregator;
this
.iEventAggregator
.GetEvent<PubSubEvent<LAInfo>>()
.Subscribe((details) =>
{
this.LAInfo = details;
});
}
Publisher xaml
<UserControl x:Class="USBReaderFinal.Views.Main"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:USBReaderFinal.Views"
xmlns:design="clr-namespace:USBReaderFinal.Designer"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="71*"/>
<RowDefinition Height="154*"/>
</Grid.RowDefinitions>
<Grid Margin="10,0,0,0" Grid.RowSpan="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="108*"/>
<ColumnDefinition Width="287*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="0*"/>
<RowDefinition Height="31*"/>
<RowDefinition Height="5*"/>
<RowDefinition Height="0*"/>
<RowDefinition Height="63*"/>
<RowDefinition Height="351*"/>
</Grid.RowDefinitions>
<!--<ContentControl Content="{Binding SelectedViewModel}" Grid.RowSpan="6" Grid.ColumnSpan="2"/>-->
<materialDesign:Card
materialDesign:ShadowAssist.ShadowDepth="Depth3"
materialDesign:ShadowAssist.ShadowEdges="Bottom"
Padding="32"
Content="LAs with Max Date.Right click the list content to Select/Add/View graphs" FontSize="16" FontStyle="Italic" FontWeight="Bold" OpacityMask="{DynamicResource {x:Static SystemColors.InfoBrushKey}}" Foreground="{DynamicResource {x:Static SystemColors.ControlDarkBrushKey}}" Grid.RowSpan="6" Grid.ColumnSpan="2" >
<materialDesign:Card.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="Black" Offset="0"/>
<GradientStop Color="#FF00FF91" Offset="1"/>
</LinearGradientBrush>
</materialDesign:Card.Background>
</materialDesign:Card>
<Frame
x:Name="NavigationFrame"
NavigationUIVisibility="Hidden"
HorizontalAlignment="Stretch"
HorizontalContentAlignment="Left"
ScrollViewer.CanContentScroll="True"
ScrollViewer.HorizontalScrollBarVisibility="Auto"
ScrollViewer.VerticalScrollBarVisibility="Auto"
Margin="6" Grid.RowSpan="6" Grid.ColumnSpan="2"
/>
<ListView Name="LA" ItemsSource="{Binding LADetails}" SelectedItem="{Binding SelectedLA}" HorizontalAlignment="Left" Height="215" VerticalAlignment="Top" Width="649" Margin="94,36,0,0" Foreground="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" Grid.Row="3" Grid.RowSpan="3" Grid.ColumnSpan="2" >
<ListView.ContextMenu>
<ContextMenu>
<MenuItem Name="Add" Header="Add New LA" />
<MenuItem Name="Update" Header="Update LA" />
<MenuItem Name="Delete" Header="Delete Selected LA" />
<MenuItem Name="Graph" Header="Display Graph" />
</ContextMenu>
</ListView.ContextMenu>
<ListView.ItemTemplate>
<DataTemplate>
<WrapPanel>
<TextBlock Text="LAName: " />
<TextBlock Text="{Binding LAname}" FontWeight="Bold" />
<TextBlock Text=", " />
<TextBlock Text=" LAMAke: " />
<TextBlock Text="{Binding LAMAke}" FontWeight="Bold" />
<TextBlock Text=" Phase: " />
<TextBlock Text="{Binding Phase}" FontWeight="Bold" />
<TextBlock Text=" Board: " />
<TextBlock Text="{Binding Board}" FontWeight="Bold" />
<TextBlock Text=" FF: " />
<TextBlock Text="{Binding Path=ld.FF}" FontWeight="Bold" />
<TextBlock Text=" CTHD: " />
<TextBlock Text="{Binding Path=ld.Cthd}" FontWeight="Bold" />
<TextBlock Text=" TTHD: " />
<TextBlock Text="{Binding Path=ld.TThd}" FontWeight="Bold" />
<TextBlock Text=" Temp: " />
<TextBlock Text="{Binding Path=ld.Temp}" FontWeight="Bold" />
<TextBlock Text=" Comptemll: " />
<TextBlock Text="{Binding Path=ld.Comptell}" FontWeight="Bold" />
<TextBlock Text=" Date: " />
<TextBlock Text="{Binding Path=ld.Max_date}" FontWeight="Bold" />
</WrapPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
</Grid>
</UserControl>
Subscriber xaml
<UserControl x:Class="USBReaderFinal.Views.PopUpFormUSB"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:prism="http://prismlibrary.com/"
prism:ViewModelLocator.AutoWireViewModel="True"
xmlns:design="clr-namespace:USBReaderFinal.Designer"
mc:Ignorable="d"
d:DesignHeight="450" Width="800">
<Grid >
<StackPanel Margin="108,0,0,0">
<Label Content="LAName" Width="71" HorizontalAlignment="Left" VerticalAlignment="Center" Foreground="DarkOrange" FontSize="14"/>
<Label Content="LAMake" Width="71" HorizontalAlignment="Left" VerticalAlignment="Center" Foreground="DarkOrange" FontSize="14"/>
<Label Content="CTHD" Width="71" HorizontalAlignment="Left" VerticalAlignment="Center" Foreground="DarkOrange" FontSize="14"/>
<Label Content="FF" Width="113" HorizontalAlignment="Left" VerticalAlignment="Center" Foreground="DarkOrange" FontSize="14"/>
<Label Content="Temp" Width="113" HorizontalAlignment="Left" VerticalAlignment="Center" Foreground="DarkOrange" FontSize="14"/>
</StackPanel>
<StackPanel Margin="345,0,0,0">
<ContentControl Grid.Row="1" Content="{Binding LAInfo}">
<ContentControl.ContentTemplate>
<DataTemplate>
</DataTemplate>
</ContentControl.ContentTemplate>
</ContentControl>
<TextBox Width="201" HorizontalAlignment="Left" VerticalAlignment="Stretch" Foreground="AliceBlue" Height="30"
Text="{Binding LAName,
Delay=1000,
Mode=TwoWay,
UpdateSourceTrigger=PropertyChanged}"
OpacityMask="#FF00A2FF" Background="{DynamicResource {x:Static SystemColors.ActiveBorderBrushKey}}" />
<TextBox Width="201" HorizontalAlignment="Left" VerticalAlignment="Center" Foreground="AliceBlue" Height="30"
Text="{Binding LAMake,
Delay=1000,
Mode=TwoWay,
UpdateSourceTrigger=PropertyChanged}" Background="{DynamicResource {x:Static SystemColors.ActiveBorderBrushKey}}" />
<TextBox Width="201" HorizontalAlignment="Left" VerticalAlignment="Center" Foreground="AliceBlue" Height="25" Text="{Binding CTHD,
Delay=1000,
Mode=TwoWay,
UpdateSourceTrigger=PropertyChanged}" Background="{DynamicResource {x:Static SystemColors.ActiveBorderBrushKey}}"/>
<TextBox Width="201" HorizontalAlignment="Left" VerticalAlignment="Center" Foreground="AliceBlue" Height="23" Text="{Binding FF,
Delay=1000,
Mode=TwoWay,
UpdateSourceTrigger=PropertyChanged}" Background="{DynamicResource {x:Static SystemColors.ActiveBorderBrushKey}}"/>
<TextBox Width="201" HorizontalAlignment="Left" VerticalAlignment="Center" Height="27" Text="{Binding Temp, Delay=1000, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Background="{DynamicResource {x:Static SystemColors.ActiveBorderBrushKey}}"/>
</StackPanel>
</Grid>
</UserControl>
Basically when I select an item from the listview of main, the selected item
should pass as an paramter to Popup view.
When I debugged the eventaggregator code, in the Subscriber VM I get null passed for the
LAInfo object in below code
public PopUpFormViewModel(IEventAggregator iEventAggregator)
{
this.iEventAggregator = iEventAggregator;
this
.iEventAggregator
.GetEvent<PubSubEvent>()
.Subscribe((details) =>
{
this.LAInfo = details;
});
}
Bootstrapper (In case required)
class BootStrapper : AutofacBootstrapper
{
protected override DependencyObject CreateShell()
{
return Container.Resolve<MainWindow>();
}
protected override void InitializeShell()
{
Application.Current.MainWindow.Show();
}
protected override void ConfigureContainerBuilder(ContainerBuilder builder)
{
base.ConfigureContainerBuilder(builder);
//builder.RegisterType<MainViewModel>().SingleInstance();
// builder.RegisterType<DataPassOnService>().As<ILAInfos>().SingleInstance();
builder.RegisterType<LADataService>().SingleInstance();
builder.RegisterType<USBDataService>().SingleInstance();
//builder.RegisterType<DataPassOnService>().SingleInstance();
builder.RegisterTypeForNavigation<Main>("Main");
builder.RegisterTypeForNavigation<LeftMenu>("LeftMenu");
builder.RegisterTypeForNavigation<PopUpFormUSB>("PopUpFormUSB");
builder.RegisterTypeForNavigation<USBListAccess>("USBListAccess");
// builder.RegisterType<USBListAccessViewModel>()
// //.As<IUSBService>()
// .UsingConstructor(typeof(USBDataService));
// builder.RegisterType<PopUpFormViewModel>().InstancePerRequest();
////.As<ILAInfos>()
//.UsingConstructor(typeof(DataPassOnService));
}
What is happening here and why I am seeing null here, this is the object which I am planning to
pass to the Subscriber xaml, which will not reach as the code will exception out due to null pointer exception.
Do I need to pass on the above selected item to NavigateTo method which will navigate to the second view with the selected parameter? If so, how do I go about doing it? I am kind of stuck. Any sort of direction is much appreciated. Thanks in advance.

WPF MVVM Combobox SelectedItem not working properly

I've already searched and read from several posts but I couldn't find what I am doing wrong.
I have a ComboBox with an ObservableCollection<string> Available_COMPorts as ItemsSource.
On SelectedValue I binded a string named SelectedCOMPort with Mode = TwoWay.
<Label Content="Porta COM: "></Label>
<ComboBox ItemsSource="{Binding Available_COMPorts}"
SelectedValue="{Binding SelectedCOMPort, Mode=TwoWay}" />
After bofere the combobox, I have a Label displaying the SelectedCOMPort
<Label Content="Status: " />
<Label Content="{Binding SelectedCOMPort}" Foreground="Red" />
I have made both Available_COMPorts and SelectedCOMPort with INotifyPropertyChanged. On my ViewModel Initialization, I filled the Available_COMPorts with the three SerialPort strings available ("COM6", "COM5", "COM4") and set SelectedCOMPort = "Available_COMPorts[0]" ("COM6").
When I Run the code, ComboBox has the three itens, the selected item is "COM6" and the label shows "COM6" (everything is fine). Then I select "COM5" and the label updates it's value to "COM5". This is presented on the following pictures.
The problem is when I try to access SelectedCOMPort on the ViewModel, as I need the selected item to connect on my SerialPort. The SelectedCOMPort is always as the default value "COM6". I try to access the SelectedCOMPorton the connect click command.
Debbuging, using Breakpoints on INotifyProperty functions I realized that the binding property seems to be working fine, but when it leaves INotifyProperty the value goes back to default.
Why is that happening? I've tryed several approachs and none worked for me.
Following is my ViewModel and BaseViewModel with INotifyProperty:
BaseViewModel : INotifyPropertyChanged
public class BaseViewModel : INotifyPropertyChanged
{
#region PropertyChange
public event PropertyChangedEventHandler PropertyChanged;
public void OnPropertyChanged([CallerMemberName] string propertyName = "")
{
if (PropertyChanged != null)
{
PropertyChanged.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
protected void SetProperty<T>(ref T backingField, T value, [CallerMemberName] string propertyName = null)
{
if (EqualityComparer<T>.Default.Equals(backingField, value)) return;
backingField = value;
OnPropertyChanged(propertyName);
}
#endregion
}
ViewModel
public class LiveGraphViewModel : BaseViewModel
{
public ConnectButtonCommand ConnectButtonCommand { get; set; }
private ObservableCollection<string> _availableCOMPorts;
private string _selectedCOMPort;
public ObservableCollection<string> Available_COMPorts
{
get { return _availableCOMPorts; }
set { SetProperty(ref _availableCOMPorts, value); }
}
public string SelectedCOMPort
{
get { return _selectedCOMPort; }
set { SetProperty(ref _selectedCOMPort, value); }
}
public LiveGraphViewModel()
{
this.ConnectButtonCommand = new ConnectButtonCommand(this);
ObservableCollection<string> TempCOM = new ObservableCollection<string>();
foreach (string comport in SerialPort.GetPortNames())
TempCOM.Add(comport);
Available_COMPorts = TempCOM;
if(Available_COMPorts.Count > 0)
SelectedCOMPort = Available_COMPorts[0];
}
public void ConnectButton()
{
if (SelectedCOMPort == "COM5")
Connect(SelectedCOMPort);
}
}
LiveGraphView XAML
<UserControl x:Class="SmartAthleticsWPF.Views.LiveGraphView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:SmartAthleticsWPF.Views"
xmlns:viewmodels="clr-namespace:SmartAthleticsWPF.ViewModels"
xmlns:commands="clr-namespace:SmartAthleticsWPF.Commands"
xmlns:syncfusion="clr-namespace:Syncfusion.UI.Xaml.Charts;assembly=Syncfusion.SfChart.WPF"
xmlns:diag="clr-namespace:System.Diagnostics;assembly=WindowsBase"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<UserControl.Resources>
<viewmodels:LiveGraphViewModel x:Key="LIVviewModel"/>
</UserControl.Resources>
<Grid Background="#EDEDED">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.01*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="0.5*"/>
<ColumnDefinition Width="0.01*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="0.1*"/>
<RowDefinition Height="1.2*"/>
<RowDefinition Height="2*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="0.1*"/>
</Grid.RowDefinitions>
<!--LIVE GRAPH BORDER-->
<Border Grid.Row="1" Grid.RowSpan="2"
Grid.Column="1" Grid.ColumnSpan="2"
Margin="5"
BorderBrush="Black"
BorderThickness="2"
CornerRadius="5"
Padding="10,10,30,10"
HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<DockPanel>
<Label Content="Live Graph"
DockPanel.Dock="Top"
HorizontalAlignment="Center"
Padding="0,5,0,10" FontSize="22"/>
<syncfusion:SfChart x:Name="LiveGraphChart" >
<syncfusion:SfChart.PrimaryAxis>
<syncfusion:NumericalAxis Header="Seconds"
Maximum="{Binding MaxXAxis}"
Minimum="{Binding MinXAxis}"/>
</syncfusion:SfChart.PrimaryAxis>
<syncfusion:SfChart.SecondaryAxis>
<syncfusion:NumericalAxis Header="Kgf"/>
</syncfusion:SfChart.SecondaryAxis>
<syncfusion:SfChart.Series>
<syncfusion:FastLineBitmapSeries ItemsSource="{Binding FyCircularBuffer}"
XBindingPath="XData" YBindingPath="YData"
StrokeThickness="1" Interior="DarkGreen"
ShowTooltip="False" ShowTrackballInfo="False"
IsSeriesVisible="{Binding FyChecked}"/>
<syncfusion:FastLineBitmapSeries ItemsSource="{Binding MyCircularBuffer}"
XBindingPath="XData" YBindingPath="YData"
StrokeThickness="1" Interior="LimeGreen"
ShowTooltip="False" ShowTrackballInfo="False"
IsSeriesVisible="{Binding MyChecked}"/>
<syncfusion:FastLineBitmapSeries ItemsSource="{Binding FxCircularBuffer}"
XBindingPath="XData" YBindingPath="YData"
StrokeThickness="1" Interior="IndianRed"
ShowTooltip="False" ShowTrackballInfo="False"
IsSeriesVisible="{Binding FxChecked}"/>
<syncfusion:FastLineBitmapSeries ItemsSource="{Binding MxCircularBuffer}"
XBindingPath="XData" YBindingPath="YData"
StrokeThickness="1" Interior="Red"
ShowTooltip="False" ShowTrackballInfo="False"
IsSeriesVisible="{Binding MxChecked}"/>
<syncfusion:FastLineBitmapSeries ItemsSource="{Binding FzCircularBuffer}"
XBindingPath="XData" YBindingPath="YData"
StrokeThickness="1" Interior="BlueViolet"
ShowTooltip="False" ShowTrackballInfo="False"
IsSeriesVisible="{Binding FzChecked}"/>
<syncfusion:FastLineBitmapSeries ItemsSource="{Binding MzCircularBuffer}"
XBindingPath="XData" YBindingPath="YData"
StrokeThickness="1" Interior="Blue"
ShowTooltip="False" ShowTrackballInfo="False"
IsSeriesVisible="{Binding MzChecked}"/>
</syncfusion:SfChart.Series>
</syncfusion:SfChart>
</DockPanel>
</Border>
<!--COP BORDER-->
<Border Grid.Row="2"
Grid.Column="3"
Margin="5"
BorderBrush="Black"
BorderThickness="2"
CornerRadius="5"
Padding="10"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch">
<DockPanel>
<Label Content="C O P"
Grid.Column="0" Grid.ColumnSpan="2"
DockPanel.Dock="Top"
HorizontalAlignment="Center"
FontSize="16"
FontWeight="Bold"
Padding="0,0,0,5"/>
<syncfusion:SfChart x:Name="CopChart"
VerticalContentAlignment="Stretch"
HorizontalAlignment="Center"
AreaBorderThickness="5"
AreaBorderBrush="#523B97">
<syncfusion:SfChart.PrimaryAxis>
<syncfusion:NumericalAxis Minimum="-20"
Maximum="20"
Interval="10"
PlotOffset="5"
BorderThickness="0"
TickLineSize="0"
FontSize="12">
<syncfusion:NumericalAxis.AxisLineStyle>
<Style TargetType="Line">
<Setter Property="StrokeThickness" Value="0"/>
</Style>
</syncfusion:NumericalAxis.AxisLineStyle>
</syncfusion:NumericalAxis>
</syncfusion:SfChart.PrimaryAxis>
<syncfusion:SfChart.SecondaryAxis>
<syncfusion:NumericalAxis Minimum="-30"
Maximum="30"
Interval="10"
PlotOffset="5"
BorderThickness="0"
TickLineSize="0"
FontSize="12">
<syncfusion:NumericalAxis.AxisLineStyle>
<Style TargetType="Line">
<Setter Property="StrokeThickness" Value="0"/>
</Style>
</syncfusion:NumericalAxis.AxisLineStyle>
</syncfusion:NumericalAxis>
</syncfusion:SfChart.SecondaryAxis>
<syncfusion:SfChart.Annotations>
<syncfusion:LineAnnotation X1="00" X2="00" Y1="-30" Y2="30"
Stroke="DimGray" StrokeThickness="2" StrokeDashArray="4"/>
<syncfusion:LineAnnotation X1="-20" X2="20" Y1="00" Y2="0"
Stroke="DimGray" StrokeThickness="2" StrokeDashArray="4"/>
</syncfusion:SfChart.Annotations>
<syncfusion:SfChart.Series>
<syncfusion:FastScatterBitmapSeries ItemsSource="{Binding COP_DOT}"
XBindingPath="XData" YBindingPath="YData"
Interior="Red" ScatterHeight="20" ScatterWidth="20"/>
</syncfusion:SfChart.Series>
</syncfusion:SfChart>
</DockPanel>
</Border>
<!--SERIAL BORDER-->
<Border Grid.Row="1"
Grid.Column="3"
Margin="5"
BorderBrush="Black"
BorderThickness="2"
CornerRadius="5"
Padding="15,0,15,0"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Label Content="Conexão"
Grid.Column="0" Grid.ColumnSpan="2"
DockPanel.Dock="Top"
HorizontalAlignment="Center"
FontSize="16"
FontWeight="Bold"
Padding="0,0,0,5"/>
<DockPanel Grid.Row="1" Grid.ColumnSpan="2" LastChildFill="True">
<Label Content="Porta COM: "></Label>
<ComboBox ItemsSource="{Binding Available_COMPorts}"
SelectedValue="{Binding SelectedCOMPort, Mode=TwoWay}"
Margin="0,0,0,15" />
<!--SelectedItem="{Binding SelectedCOMPort, Mode=TwoWay, diag:PresentationTraceSources.TraceLevel=High}"-->
</DockPanel>
<Button Grid.Row="2" Grid.ColumnSpan="2" Content="Connect/Disconnect" HorizontalAlignment="Stretch" Margin="5"
Command="{Binding Path=ConnectButtonCommand, Source={StaticResource LIVviewModel}}"/>
<StackPanel Orientation="Horizontal" Grid.Row="3" Grid.ColumnSpan="2">
<Label Content="Status: "></Label>
<Label Content="{Binding SelectedCOMPort}" Foreground="Red" />
</StackPanel>
</Grid>
</Border>
<Grid Grid.Row="3"
Grid.Column="1" Grid.ColumnSpan="3"
HorizontalAlignment="Stretch">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<!--SERIAL BORDER-->
<Border Grid.Column="0"
Margin="5"
BorderBrush="Black"
BorderThickness="2"
CornerRadius="5"
Padding="20,0,20,0">
</Border>
<!--RECORD BORDER-->
<Border Grid.Column="1"
Margin="5"
BorderBrush="Black"
BorderThickness="2"
CornerRadius="5"
Padding="20,0,20,0">
<Grid Margin="5,10,5,10" VerticalAlignment="Stretch">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="2*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="1.5*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Button Grid.Row="0" Grid.ColumnSpan="2" Margin="0,0,0,10"
Content="Click me" Command="{Binding Path=RecordButtonCommand, Source={StaticResource LIVviewModel}}" />
<Label Content="Record Time (s):"
Grid.Column="0" Grid.Row="1" VerticalAlignment="Center"/>
<TextBlock Text="30" Background="White"
Grid.Column="1" Grid.Row="1"
VerticalAlignment="Center"/>
<Label Content="Name:"
Grid.Column="0" Grid.Row="2" VerticalAlignment="Center"/>
<TextBlock Text="Subject Name"
Grid.Column="1" Grid.Row="2" VerticalAlignment="Center"/>
</Grid>
</Border>
<!--Informações do Gráfico BORDER-->
<Border Grid.Column="2"
Margin="5"
BorderBrush="Black"
BorderThickness="2"
CornerRadius="5"
Padding="10,0,10,0">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Label Content="Informações do Gráfico"
Grid.Column="0" Grid.ColumnSpan="6"
HorizontalAlignment="Center"
FontSize="16" FontWeight="Bold" />
<CheckBox Content="Fy"
Grid.Column="0" Grid.Row="1"
FontWeight="ExtraBlack" FontSize="12"
Foreground="DarkGreen"
HorizontalAlignment="Center"
IsChecked="{Binding FyChecked}" />
<CheckBox Content="My"
Grid.Column="1" Grid.Row="1"
FontWeight="ExtraBlack" FontSize="12"
Foreground="LimeGreen"
HorizontalAlignment="Center"
IsChecked="{Binding MyChecked}" />
<CheckBox Content="Fx"
Grid.Column="2" Grid.Row="1"
FontWeight="ExtraBlack" FontSize="12"
Foreground="IndianRed"
HorizontalAlignment="Center"
IsChecked="{Binding FxChecked}" />
<CheckBox Content="Mx"
Grid.Column="3" Grid.Row="1"
FontWeight="ExtraBlack" FontSize="12"
Foreground="Red"
HorizontalAlignment="Center"
IsChecked="{Binding MxChecked}" />
<CheckBox Content="Fz"
Grid.Column="4" Grid.Row="1"
FontWeight="ExtraBlack" FontSize="12"
Foreground="BlueViolet"
HorizontalAlignment="Center"
IsChecked="{Binding FzChecked}" />
<CheckBox Content="Mz"
Grid.Column="5" Grid.Row="1"
FontWeight="ExtraBlack" FontSize="12"
Foreground="Blue"
HorizontalAlignment="Center"
IsChecked="{Binding MzChecked}" />
<DockPanel Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="3" LastChildFill="True" HorizontalAlignment="Stretch">
<Label Content="Periodo: " VerticalAlignment="Center"/>
<ComboBox Text="30" Background="White" VerticalAlignment="Center"
SelectedIndex="{Binding PeriodSelectedIndex}"> <!--5-->
<ComboBoxItem Content="100 ms" />
<ComboBoxItem Content="500 ms" />
<ComboBoxItem Content="1 s" />
<ComboBoxItem Content="5 s" />
<ComboBoxItem Content="10 s" />
<ComboBoxItem Content="30 s" />
</ComboBox>
</DockPanel>
<DockPanel Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="3" LastChildFill="True" HorizontalAlignment="Stretch">
<Label Content="Amplitude: " VerticalAlignment="Center"/>
<ComboBox Text="30" Background="White" VerticalAlignment="Center"
SelectedIndex="{Binding AmplitudeSelectedIndex}"> <!--3-->
<ComboBoxItem Content="10"/>
<ComboBoxItem Content="100"/>
<ComboBoxItem Content="500"/>
<ComboBoxItem Content="1000"/>
<ComboBoxItem Content="5000"/>
<ComboBoxItem Content="10000"/>
</ComboBox>
</DockPanel>
<Label Grid.Row="2" Grid.Column="3" Grid.ColumnSpan="3" Content="{Binding PesoKg}" ContentStringFormat="Peso (kg): {0}" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<Label Grid.Row="3" Grid.Column="3" Grid.ColumnSpan="3" Content="{Binding PesoNw}" ContentStringFormat="Força (N): {0}" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</Grid>
</Border>
</Grid>
</Grid>
</UserControl>
Connect Button
public class ConnectButtonCommand : ICommand
{
public LiveGraphViewModel ViewModel { get; set; }
public ConnectButtonCommand(LiveGraphViewModel viewModel)
{
this.ViewModel = viewModel;
}
public event EventHandler CanExecuteChanged;
public bool CanExecute(object parameter)
{
return true;
}
public void Execute(object parameter)
{
this.ViewModel.ConnectButton();
}
}
DataContext
public partial class LiveGraphView : UserControl
{
private LiveGraphViewModel _vm;
public LiveGraphView()
{
InitializeComponent();
this._vm = new LiveGraphViewModel();
this.DataContext = this._vm;
}
}
As mentioned by #Clemens I had two view model instances at the same time.
One created in the UserControl's constructor (code behind) and other on the XAML Resources.
So, I removed the last one and everything works fine.
<!--
<UserControl.Resources>
<viewmodels:LiveGraphViewModel x:Key="LIVviewModel"/>
</UserControl.Resources>
-->
<Label Content="Porta COM: "></Label>
<ComboBox ItemsSource="{Binding Available_COMPorts}"
SelectedValue="{Binding SelectedCOMPort, Mode=TwoWay}" />
<Button Content="Connect/Disconnect"
Command="{Binding Path=ConnectButtonCommand}" />

How to insert paaswordbox value into database table?

I used PasswordHelper class to bind passwordbox with viewmodel but still property field is null at submit time. i tried with debugger but property doesn't getting value.
XAML Code..
<Page x:Class="ChatApp.View.Register"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
xmlns:se="http://schemas.microsoft.com/expression/2010/interactions"
xmlns:vm="clr-namespace:ChatApp.ViewModel"
xmlns:w="clr-namespace:ChatApp"
mc:Ignorable="d"
d:DesignHeight="347" d:DesignWidth="350"
Title="Register">
<Page.DataContext>
<vm:RegisterViewModel></vm:RegisterViewModel>
</Page.DataContext>
<Grid Height="317">
<Grid.RowDefinitions>
<RowDefinition Height="30" />
<RowDefinition Height="30" />
<RowDefinition Height="30" />
<RowDefinition Height="30" />
<RowDefinition Height="30" />
<RowDefinition Height="30" />
<RowDefinition Height="63" />
<RowDefinition Height="32" />
<RowDefinition Height="42*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="112*"/>
<ColumnDefinition Width="188*" />
</Grid.ColumnDefinitions>
<Label Content="User ID :" Grid.Row="1" Height="28" HorizontalAlignment="Left" Margin="12,0,0,0" Name="label1" VerticalAlignment="Top" />
<Label Content="Password :" Grid.Row="2" Height="28" HorizontalAlignment="Left" Margin="12,2,0,0" Name="label2" VerticalAlignment="Top" />
<Label Content="Name" Grid.Row="3" Height="28" HorizontalAlignment="Left" Margin="12,0,0,0" Name="label3" VerticalAlignment="Top" />
<Label Content="Email ID :" Grid.Row="4" Height="28" HorizontalAlignment="Left" Margin="12,2,0,0" Name="label4" VerticalAlignment="Top" />
<Label Content="Contact No :" Grid.Row="5" Height="29" HorizontalAlignment="Left" Margin="12,1,0,0" Name="label5" VerticalAlignment="Top" />
<Label Content="Address :" Grid.Row="6" Height="28" HorizontalAlignment="Left" Margin="12,0,0,0" Name="label6" VerticalAlignment="Top" />
<Label Content="Designation :" Grid.Row="7" Height="28" HorizontalAlignment="Left" Margin="12,0,0,0" Name="label7" VerticalAlignment="Top" />
<TextBox Text="{Binding userID}" Grid.Column="1" Grid.Row="1" Height="23" HorizontalAlignment="Left" Margin="0,3,0,0" Name="txtID" VerticalAlignment="Top" Width="207" />
<TextBox Grid.Column="1" Text="{Binding password}" Grid.Row="2" Height="23" HorizontalAlignment="Left" Name="txtpassword" VerticalAlignment="Top" Width="207" Margin="0,2,0,0" />
<TextBox Text="{Binding name}" Grid.Column="1" Grid.Row="3" Height="23" HorizontalAlignment="Left" Name="txtName" VerticalAlignment="Top" Width="207" Margin="0,2,0,0" />
<TextBox Text="{Binding emailID}" Grid.Column="1" Grid.Row="4" Height="23" HorizontalAlignment="Left" Margin="0,2,12,0" Name="txtEmail" VerticalAlignment="Top" Width="207" />
<TextBox Text="{Binding contact}" Grid.Column="1" Grid.Row="5" Height="23" HorizontalAlignment="Left" Name="txtContact" VerticalAlignment="Top" Width="207" Margin="0,2,0,0" />
<TextBox Text="{Binding address}" Grid.Column="1" Grid.Row="6" Height="56" HorizontalAlignment="Left" Margin="0,2,0,0" Name="txtAddress" VerticalAlignment="Top" Width="207" TextWrapping="Wrap" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" />
<TextBox Text="{Binding designation}" Grid.Column="1" Grid.Row="7" Height="23" HorizontalAlignment="Left" Name="txtDesignation" VerticalAlignment="Top" Width="207" Margin="0,1,0,0" />
<TextBlock Height="28" HorizontalAlignment="Left" Margin="49,1,0,0" Name="textBlock1" Text="New Registration" VerticalAlignment="Top" Width="169" Grid.ColumnSpan="2" FontWeight="Bold" FontSize="20" />
<Button Content="Register" Grid.Row="8" Height="23" HorizontalAlignment="Left" Margin="33,5,0,0" Name="btnSubmit" VerticalAlignment="Top" Width="75" Grid.Column="1">
<i:Interaction.Triggers>
<i:EventTrigger SourceObject="{Binding ElementName=btnSubmit}" EventName="Click">
<se:CallMethodAction MethodName="SubmitDetail" TargetObject="{Binding DataContext, ElementName=btnSubmit}" />
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
</Grid>
here is my password helper class.
public static class PasswordHelper
{
public static readonly DependencyProperty PasswordProperty =
DependencyProperty.RegisterAttached("Password",
typeof(string), typeof(PasswordHelper),
new FrameworkPropertyMetadata(string.Empty, OnPasswordPropertyChanged));
public static readonly DependencyProperty AttachProperty =
DependencyProperty.RegisterAttached("Attach",
typeof(bool), typeof(PasswordHelper), new PropertyMetadata(false, Attach));
private static readonly DependencyProperty IsUpdatingProperty =
DependencyProperty.RegisterAttached("IsUpdating", typeof(bool),
typeof(PasswordHelper));
public static void SetAttach(DependencyObject dp, bool value)
{
dp.SetValue(AttachProperty, value);
}
public static bool GetAttach(DependencyObject dp)
{
return (bool)dp.GetValue(AttachProperty);
}
public static string GetPassword(DependencyObject dp)
{
return (string)dp.GetValue(PasswordProperty);
}
public static void SetPassword(DependencyObject dp, string value)
{
dp.SetValue(PasswordProperty, value);
}
private static bool GetIsUpdating(DependencyObject dp)
{
return (bool)dp.GetValue(IsUpdatingProperty);
}
private static void SetIsUpdating(DependencyObject dp, bool value)
{
dp.SetValue(IsUpdatingProperty, value);
}
private static void OnPasswordPropertyChanged(DependencyObject sender,
DependencyPropertyChangedEventArgs e)
{
PasswordBox passwordBox = sender as PasswordBox;
passwordBox.PasswordChanged -= PasswordChanged;
if (!(bool)GetIsUpdating(passwordBox))
{
passwordBox.Password = (string)e.NewValue;
}
passwordBox.PasswordChanged += PasswordChanged;
}
private static void Attach(DependencyObject sender, DependencyPropertyChangedEventArgs e)
{
PasswordBox passwordBox = sender as PasswordBox;
if (passwordBox == null)
return;
if ((bool)e.OldValue)
{
passwordBox.PasswordChanged -= PasswordChanged;
}
if ((bool)e.NewValue)
{
passwordBox.PasswordChanged += PasswordChanged;
}
}
private static void PasswordChanged(object sender, RoutedEventArgs e)
{
PasswordBox passwordBox = sender as PasswordBox;
SetIsUpdating(passwordBox, true);
SetPassword(passwordBox, passwordBox.Password);
SetIsUpdating(passwordBox, false);
}
}
I see two problems with your code:
1.
XAML is case sensitive with regards to binding paths, but you have used lower cased property names in your XAML. (You can find out more from the 'Case and Whitespace in XAML' section of the XAML Overview (WPF) page at MSDN.
XAML is generally speaking case sensitive. For purposes of resolving backing types, WPF XAML is case sensitive by the same rules that the CLR is case sensitive. Object elements, property elements, and attribute names must all be specified by using the sensitive casing when compared by name to the underlying type in the assembly, or to a member of a type.
2.
You do not need to set the Password property of the PasswordBox in your OnPasswordPropertyChanged handler, although this shouldn't cause your described problem.

Databinding custom objects

public class Employee : INotifyPropertyChanged
{
// Private Properties
private string _name;
private List<string> _address;
// The Public properties for which the getters and setters are implemented appropriately (raising OnPropertyChanged event)
}
public class EmployeeRecords: ObservableCollection<Employee>
{
public bool AddEmployee(Employee employee)
{
Add(employee);
return true;
}
public bool RemoveEmployee(int index)
{
if (Count > 0)
{
RemoveAt(index); // is the same as doing 'RemoveAt(SelectedIndex);'
}
return true;
}
}
**XAML:**
<Window x:Class="EmployeeInfo.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:src="clr-namespace:EmployeeInfo"
Name="Page1" Height="225" Width="610"
Title="DATABINDING DEMO">
<Window.Resources>
<DataTemplate x:Key="EmployeeTemplate">
<StackPanel>
<TextBlock Text="{Binding Path=Name}" />
<TextBlock Text="{Binding Path=EmpId}"/>
<TextBlock Text="{Binding Path=Designation}"/>
</StackPanel>
</DataTemplate>
<src:EmployeeRecords x:Key="EmpInfo"/>
</Window.Resources>
<Window.DataContext>
<Binding Source="{StaticResource EmpInfo}"/>
</Window.DataContext>
<Canvas Height="190" Width="600">
<Label Name="lblName" Height="30" Width="50" Canvas.Top="0" Canvas.Left="0" >Name</Label>
<TextBox Name="txtBoxName" Height="30" Width="125" Text="{Binding Path=Name}" Canvas.Top="5" Canvas.Left="60" />
<Label Name="lblEmpId" Height="30" Width="50" Canvas.Top="40" Canvas.Left="0" >EmpId</Label>
<TextBox Name="txtBoxEmpId" Height="30" Width="50" Text="{Binding Path=EmpId}" Canvas.Top="40" Canvas.Left="60" />
<Label Name="lblDesignation" Height="30" Width="50" Canvas.Top="75" Canvas.Left="0" >Designation</Label>
<TextBox Name="txtBoxDesignation" Height="30" Width="50" Text="{Binding Path=Designation}" Canvas.Top="75" Canvas.Left="60" />
<Label Name="lblAddress" Height="30" Width="50" Canvas.Top="115" Canvas.Left="0" >Address</Label>
<TextBox Name="txtBoxAddress" Height="30" Width="50" Text="{Binding Path=Address}" Canvas.Top="115" Canvas.Left="60" />
<TextBox Name="txtBoxAddress2" Height="30" Width="50" Text="{Binding Path=Address}" Canvas.Top="115" Canvas.Left="120" />
<Button Height="30" Width="50" Canvas.Top="155" Canvas.Left="0" Content="Update" Click="UpdateButton_Click"/>
<Button Height="30" Width="50" Canvas.Top="155" Canvas.Left="60" Content="Submit" Click="SubmitButton_Click"/>
<Button Height="30" Width="50" Canvas.Top="155" Canvas.Left="120" Content="Remove" Click="RemoveButton_Click" />
<ListBox SelectedIndex="{Binding SelectedIndex}"
MouseDoubleClick="LstEmployee_MouseDoubleClick" Name="lstEmployee" Height="180" Width="190"
Canvas.Top="5" Canvas.Left="200" ItemsSource="{Binding}" ItemTemplate="{StaticResource EmployeeTemplate}"/>
<ListBox Name="listAddress" Height="180" Width="190" Canvas.Top="5" Canvas.Left="400" ItemsSource="{Binding Path=/Address}"/>
</Canvas>
</Window>
MainWindow.xaml.cs:
public partial class MainWindow : Window
{
private EmployeeRecords _empRecords;
public MainWindow()
{
InitializeComponent();
Initialize();
lstEmployee.ItemsSource = _empRecords;
}
.
.
.
.
}
I'm trying to display all the properties of Employee in the 1st listBox and just the addresses in the 2nd ListBox. Can someone tell me what i'm doing wrong here?
Since I can't explicitly access the Employee object within EmployeeRecords, how can I bind the Address list inside of Employee to a control?
Thanks in advance!
Shanks
Assuming that you want to display the address of the selected Employee in the second ListBox, the following should work.
<ListBox Grid.Row="1" Name="listAddress" Height="180" Width="190" Canvas.Top="5" Canvas.Left="400" ItemsSource="{Binding ElementName=lstEmployee, Path=SelectedItem.Address}"/>
Note:
I have assumed that the public property name for the backing field private List<string> _address; is Address

Some squares like hints in Silverlight application - how to remove them?

Good day!
Strange square appears on mouse hover on text boxes, buttons, etc (something like hint) in a silverlight navigation application - how can I remove it?
A print screen
http://i34.photobucket.com/albums/d126/durick/bug.jpg
I've colored the square at a picture. It appears when the mouse hover.
an example .xaml page:
<Code:BasePage x:Class="CAP.Views.Main"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
xmlns:Code="clr-namespace:CAP.Code"
d:DesignWidth="640" d:DesignHeight="480"
Title="Личный кабинет клиентов ООО АУРИТ">
<Grid x:Name="LayoutRoot">
<Grid.RowDefinitions>
<RowDefinition Height="103*" />
<RowDefinition Height="377*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="120*" />
<ColumnDefinition Width="520*" />
</Grid.ColumnDefinitions>
<Image Height="85" HorizontalAlignment="Left" Name="image1" Stretch="Fill" VerticalAlignment="Top" Width="84" Margin="12,0,0,0" ImageFailed="image1_ImageFailed" Source="/CAP;component/Images/My-Computer.png" />
<TextBlock Grid.Column="1" Height="Auto" TextWrapping="Wrap" HorizontalAlignment="Left" Margin="0,12,0,0" Name="textBlock1" Text="Good day!" VerticalAlignment="Top" FontFamily="Verdana" FontSize="16" Width="345" FontWeight="Bold" />
<TextBlock Grid.Column="1" Grid.Row="1" TextWrapping="Wrap" Height="299" HorizontalAlignment="Left" Name="textBlock2" VerticalAlignment="Top" FontFamily="Verdana" FontSize="14" Width="441" >
<Run Text="Some text "/><LineBreak/><LineBreak/><Run Text="and so on"/>
<LineBreak/>
</TextBlock>
</Grid>
.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Navigation;
using CAP.Code;
namespace CAP.Views
{
public partial class Main : BasePage
{
public Main() : base()
{
InitializeComponent();
MapBuilder.AddToMap(new SiteMapUnit() { Caption = "Главная", RelativeUrl = "Main" },true);
((App)Application.Current).Mainpage.tvMainMenu.SelectedItems.Clear();
}
// Executes when the user navigates to this page.
protected override void OnNavigatedTo(NavigationEventArgs e)
{
}
private void image1_ImageFailed(object sender, ExceptionRoutedEventArgs e)
{
}
protected override string[] NeededPermission()
{
return new string[0];
}
}
}
MainPage.xaml
<UserControl
x:Class="CAP.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Code="clr-namespace:CAP.Code"
xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
xmlns:uriMapper="clr-namespace:System.Windows.Navigation;assembly=System.Windows.Controls.Navigation"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls"
xmlns:telerikNavigation="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation"
mc:Ignorable="d" Margin="0,0,0,0" Width="auto" Height="auto" xmlns:dataInput="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data.Input">
<ScrollViewer Width="auto" Height="auto" BorderBrush="White" BorderThickness="0" Margin="0,0,0,0" x:Name="sV" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" >
<ScrollViewer.Content>
<Grid Width="auto" Height="auto" x:Name="LayoutRoot" Style="{StaticResource LayoutRootGridStyle}" Margin="0,0,0,0">
<StackPanel Width="auto" Height="auto" Orientation="Vertical" Margin="250,0,0,50">
<Border x:Name="ContentBorder2" Margin="0,0,0,0" >
<!--<navigation:Frame Margin="0,0,0,0" Width="auto" Height="auto" x:Name="AnotherFrame" VerticalAlignment="Top" Style="{StaticResource ContentFrameStyle}" Source="/Views/Menu.xaml" NavigationFailed="ContentFrame_NavigationFailed" JournalOwnership="OwnsJournal" Loaded="AnotherFrame_Loaded">
</navigation:Frame>-->
<StackPanel Orientation="Vertical" Height="82" Width="Auto" HorizontalAlignment="Right" Margin="0,0,0,0" DataContext="{Binding}">
<TextBlock HorizontalAlignment="Right" Foreground="White" x:Name="ApplicationNameTextBlock4" Style="{StaticResource ApplicationNameStyle}" FontSize="20"
Text="Личный кабинет" Margin="20,16,20,0"/>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
<Image x:Name="imDoor" Visibility="Collapsed" MouseEnter="imDoor_MouseEnter" MouseLeave="imDoor_MouseLeave" Height="24" Stretch="Fill" Width="25" Margin="10,0,10,0" Source="/CAP;component/Images/sm_white_doors.png" MouseLeftButtonDown="bTest_Click" />
<TextBlock x:Name="bLogout" MouseEnter="bLogout_MouseEnter" MouseLeave="bLogout_MouseLeave" TextDecorations="Underline" Margin="0,6,20,4" Height="23" Text="Выйти" HorizontalAlignment="Right" Visibility="Collapsed" MouseLeftButtonDown="bTest_Click" FontFamily="Verdana" FontSize="13" FontWeight="Normal" Foreground="#FF1C1C92" />
</StackPanel>
</StackPanel>
</Border>
<Border x:Name="bSiteMap" Margin="0,0,0,0" >
<StackPanel x:Name="spSiteMap" Orientation="Horizontal" Height="20" Width="Auto" HorizontalAlignment="Left" Margin="0,0,0,0" DataContext="{Binding}">
<!-- <TextBlock Visibility="Visible" TextDecorations="Underline" Height="23" HorizontalAlignment="Left" x:Name="ar" Text="1" VerticalAlignment="Top" Foreground="Blue" FontFamily="Verdana" FontSize="13" />
<TextBlock Visibility="Visible" Height="23" HorizontalAlignment="Left" x:Name="Map" Text="->" VerticalAlignment="Top" Foreground="Blue" FontFamily="Verdana" FontSize="13" />
<TextBlock Visibility="Visible" TextDecorations="Underline" Height="23" HorizontalAlignment="Left" x:Name="ar1" Text="2" VerticalAlignment="Top" Foreground="Blue" FontFamily="Verdana" FontSize="13" />
<TextBlock Visibility="Visible" Height="23" HorizontalAlignment="Left" x:Name="Map1" Text="->" VerticalAlignment="Top" Foreground="Blue" FontFamily="Verdana" FontSize="13" />
<TextBlock Visibility="Visible" TextDecorations="Underline" Height="23" HorizontalAlignment="Left" x:Name="ar2" Text="3" VerticalAlignment="Top" Foreground="Blue" FontFamily="Verdana" FontSize="13" />-->
</StackPanel>
</Border>
<Border Width="auto" Height="auto" x:Name="ContentBorder" Margin="0,0,0,0" >
<navigation:Frame x:Name="ContentFrame" Style="{StaticResource ContentFrameStyle}"
Source="Main" Navigated="ContentFrame_Navigated" NavigationFailed="ContentFrame_NavigationFailed" ToolTipService.ToolTip=" " Margin="0,0,0,0">
<navigation:Frame.UriMapper>
<uriMapper:UriMapper>
<!--Client-->
<uriMapper:UriMapping Uri="RegistrateClient" MappedUri="/Views/Client/RegistrateClient.xaml"/>
<!--So on-->
</uriMapper:UriMapper>
</navigation:Frame.UriMapper>
</navigation:Frame>
</Border>
</StackPanel>
<Grid x:Name="NavigationGrid" Style="{StaticResource NavigationGridStyle}" Margin="0,0,0,0" Background="{x:Null}" >
<StackPanel Orientation="Vertical" Height="Auto" Width="250" HorizontalAlignment="Center" Margin="0,0,0,50" DataContext="{Binding}">
<Image Width="150" Height="90" HorizontalAlignment="Center" VerticalAlignment="Top" Source="/CAP;component/Images/logo__au.png" Margin="0,20,0,70"/>
<Border x:Name="BrandingBorder" MinHeight="222" Width="250" Style="{StaticResource BrandingBorderStyle3}" HorizontalAlignment="Center" Opacity="60" Margin="0,0,0,0">
<Border.Background>
<ImageBrush ImageSource="/CAP;component/Images/papka.png"/>
</Border.Background>
<Grid Width="250" x:Name="LichniyCabinet" Margin="0,10,0,0" HorizontalAlignment="Center" Height="211">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="19*" />
<ColumnDefinition Width="62*" />
<ColumnDefinition Width="151*" />
<ColumnDefinition Width="18*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="13" />
<RowDefinition Height="24" />
<RowDefinition Height="35" />
<RowDefinition Height="35" />
<RowDefinition Height="43" />
<RowDefinition Height="28" />
<RowDefinition Height="32*" />
</Grid.RowDefinitions>
<TextBlock Visibility="Visible" Grid.Row="2" Height="23" HorizontalAlignment="Left" x:Name="tLogin" Text="Логин" VerticalAlignment="Top" FontFamily="Verdana" FontSize="13" Foreground="White" Margin="1,0,0,0" Grid.Column="1" />
<TextBlock Visibility="Visible" FontFamily="Verdana" FontSize="13" Foreground="White" Height="23" HorizontalAlignment="Left" x:Name="tPassw" Text="Пароль" VerticalAlignment="Top" Grid.Row="3" Grid.Column="1" />
<TextBox Visibility="Visible" Grid.Column="2" Grid.Row="2" Height="24" HorizontalAlignment="Left" x:Name="logLogin" VerticalAlignment="Top" Width="150" />
<PasswordBox Visibility="Visible" Code:DefaultButtonService.DefaultButton="{Binding ElementName=bLogin}" PasswordChar="*" Height="24" HorizontalAlignment="Left" x:Name="logPassword" VerticalAlignment="Top" Width="150" Grid.Column="2" Grid.Row="3" />
<Button x:Name="bLogin" MouseEnter="bLogin_MouseEnter" MouseLeave="bLogin_MouseLeave" Visibility="Visible" Content="Войти" Grid.Column="2" Grid.Row="4" Click="Button_Click" Height="23" HorizontalAlignment="Left" Margin="81,0,0,0" VerticalAlignment="Top" Width="70" />
<TextBlock MouseLeftButtonDown="ForgotPassword_MouseLeftButtonDown" MouseEnter="ForgotPassword_MouseEnter" MouseLeave="ForgotPassword_MouseLeave" Visibility="Visible" TextDecorations="Underline" Grid.ColumnSpan="2" Grid.Row="4" Height="23" HorizontalAlignment="Left" x:Name="ForgotPassword" Text="Забыли пароль?" VerticalAlignment="Top" Foreground="White" FontFamily="Verdana" FontSize="13" Grid.Column="1" />
<TextBlock MouseEnter="tbRegistration_MouseEnter" MouseLeave="tbRegistration_MouseLeave" MouseLeftButtonDown="tbRegistration_MouseLeftButtonDown" Grid.Column="2" Grid.Row="6" Height="23" x:Name="tbRegistration" TextDecorations="Underline" Text="Регистрация" VerticalAlignment="Top" FontFamily="Verdana" FontSize="13" TextAlignment="Center" HorizontalAlignment="Center" Foreground="#FF1C1C92" FontWeight="Normal" Margin="0,0,57,0" />
<TextBlock Cursor="Arrow" Height="23" HorizontalAlignment="Left" Margin="11,-3,0,0" Text="Личный кабинет" VerticalAlignment="Top" Grid.ColumnSpan="3" Grid.RowSpan="2" FontFamily="Verdana" FontSize="13" FontWeight="Bold" Foreground="White" />
<Image Visibility="Collapsed" Height="70" x:Name="imUser" Stretch="Fill" Width="70" Grid.ColumnSpan="2" Margin="11,0,0,0" Grid.Row="2" Grid.RowSpan="2" Source="/CAP;component/Images/user2.png" />
<TextBlock x:Name="tbHello" Grid.Column="2" Visibility="Collapsed" Grid.Row="2" Height="auto" TextWrapping="Wrap" HorizontalAlignment="Left" Margin="6,0,0,0" Text="" VerticalAlignment="Top" FontFamily="Verdana" FontSize="13" Foreground="White" Width="145" />
</Grid>
</Border>
<Border x:Name="MenuBorder" Margin="0,0,0,50" Width="250" Visibility="Collapsed">
<StackPanel x:Name="spMenu" Width="240" HorizontalAlignment="Left">
<telerikNavigation:RadTreeView x:Name="tvMainMenu"
Width="240"
Selected="TreeView1_Selected"
SelectedValuePath="Text"
telerik:Theming.Theme="Windows7"
FontFamily="Verdana"
FontSize="12"/>
</StackPanel>
</Border>
</StackPanel>
</Grid>
<Border x:Name="FooterBorder" VerticalAlignment="Bottom" Width="auto" Height="76">
<Border.Background>
<ImageBrush ImageSource="/CAP;component/Images/footer2.png" />
</Border.Background>
<TextBlock x:Name="tbFooter" Height="24" Width="auto" Margin="0,20,0,0" TextAlignment="Center" HorizontalAlignment="Stretch" VerticalAlignment="Center" Foreground="White" FontFamily="Verdana" FontSize="11">
</TextBlock>
</Border>
</Grid>
</ScrollViewer.Content>
</ScrollViewer>
</UserControl>
MainPage.xaml.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Navigation;
using CAP.Code;
using CAP.Registrator;
using System.Windows.Input;
using System.ComponentModel.DataAnnotations;
using System.Windows.Browser;
using Telerik.Windows.Controls;
using System.Net;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace CAP
{
public partial class MainPage
{
public App Appvars = Application.Current as App;
private readonly RegistratorClient registrator;
public SiteMapBuilder builder;
public MainPage()
{
InitializeComponent();
sV.SetIsMouseWheelScrollingEnabled(true);
builder = new SiteMapBuilder(spSiteMap);
try
{
//working with service
}
catch
{
this.ContentFrame.Navigate(new Uri(String.Format("ErrorPage"), UriKind.RelativeOrAbsolute));
}
}
/// Recursive method to update the correct scrollviewer (if exists)
private ScrollViewer CheckParent(FrameworkElement element)
{
ScrollViewer _result = element as ScrollViewer;
if (element != null && _result == null)
{
FrameworkElement _temp = element.Parent as FrameworkElement;
_result = CheckParent(_temp);
}
return _result;
}
// If an error occurs during navigation, show an error window
private void ContentFrame_NavigationFailed(object sender, NavigationFailedEventArgs e)
{
e.Handled = true;
ChildWindow errorWin = new ErrorWindow(e.Uri);
errorWin.Show();
}
}
}
here it is a screen shot
http://i34.photobucket.com/albums/d126/durick/1-1.gif
i've solved the problem!!!
it was only a property ToolTipService.ToolTip=" " of Navigation:Frame
!!!!!!!!!!!!!!!!!!!!!!

Resources