Posts

Validation By IDataErrorInfo in Wpf using MVVM

<Window x:Class="WpfPrismTutorial.Views.MainWindow"         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"         xmlns:local="clr-namespace:WpfPrismTutorial"         mc:Ignorable="d"         prism:ViewModelLocator.AutoWireViewModel="True"         xmlns:prism="http://prismlibrary.com/"         xmlns:valid="clr-namespace:WpfPrismTutorial.Validations"         Title="MainWindow" Height="450" Width="800">     <Window.Resources>         <ControlTemplate x:Key=" errorTemplate ">             <StackPanel Orientation="Horizontal">             <AdornedElementPlaceholder x:Name

Validation By Annotation in Wpf using MVVM

View  <Window x:Class="WpfPrismTutorial.Views.MainWindow"         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"         xmlns:local="clr-namespace:WpfPrismTutorial"         mc:Ignorable="d"         prism:ViewModelLocator.AutoWireViewModel="True"         xmlns:prism="http://prismlibrary.com/"         xmlns:valid="clr-namespace:WpfPrismTutorial.Validations"         Title="MainWindow" Height="450" Width="800">     <Window.Resources>         <ControlTemplate x:Key=" errorTemplate ">             <StackPanel Orientation="Horizontal">             <AdornedElementPlaceholder x:

Validation By Exception in Wpf using MVVM

Image
View <Window x:Class="WpfPrismTutorial.Views.MainWindow"         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"         xmlns:local="clr-namespace:WpfPrismTutorial"         mc:Ignorable="d"         prism:ViewModelLocator.AutoWireViewModel="True"         xmlns:prism="http://prismlibrary.com/"         xmlns:valid="clr-namespace:WpfPrismTutorial.Validations"         Title="MainWindow" Height="450" Width="800">     <Window.Resources>         <ControlTemplate x:Key=" errorTemplate ">             <StackPanel Orientation="Horizontal">             <AdornedElementPlaceholder x:N

How to change background color of TabItems on mouse over?

<TabControl >             <TabControl.ItemContainerStyle>                 <Style TargetType="TabItem" BasedOn="{StaticResource {x:Type TabItem}}">                     <Setter Property="HeaderTemplate">                         <Setter.Value>                             <DataTemplate>                                 <StackPanel Orientation="Horizontal" Margin="5" >                                     <StackPanel.Style>                                         <Style TargetType="StackPanel">                                             <Setter Property="Background" Value="Red"/>                                             <Style.Triggers>                                                 <Trigger Property="IsMouseOver" Value="true">                                                     <Setter Property="

Easy way of navigate using Prism in WPF

Image
1. First.xaml <UserControl x:Class="PrismMain.Views.First"              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:PrismMain.Views"              mc:Ignorable="d"              xmlns:prism="http://prismlibrary.com/"         prism:ViewModelLocator.AutoWireViewModel="True">     <StackPanel>           <Button Content="Navigate To Second" Margin="5"  Command="{Binding NavigateCommand}" Width="150"/>     </StackPanel> </UserControl> First.xaml.cs public partial class First: UserControl     {         pu

How to Create TabControl using Prism Region

Image
MainWindow <metro:MetroWindow x:Class="PrismDemo.Views.MainWindow"         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"         xmlns:local="clr-namespace:PrismDemo.Views"         mc:Ignorable="d" xmlns:prism="http://prismlibrary.com/"         Title="MetroPrismDemo"         xmlns:metro="http://metro.mahapps.com/winfx/xaml/controls">     <Grid>         <TabControl Margin="5" prism:RegionManager.RegionName =" TabRegion "                   VerticalAlignment="Stretch" HorizontalAlignment="Left" BorderThickness="0">         </TabControl>     </Grid> </metro:Metr

How to create TextBox in wpf that does not accept number using MVVM?

Image
Method 1: Using Model Property Inside View <TextBox Width="200" Text="{Binding MainWindowModel.NonNumeric,UpdateSourceTrigger=PropertyChanged}"> Inside Model  private string _nonNumeric;         public string NonNumeric         {             get { return _nonNumeric; }             set             {                 int intvalue;                 if (!int.TryParse(value[value.Length - 1].ToString(), out intvalue))                     SetProperty(ref _nonNumeric, value);                 else                     value = _nonNumeric;             }         } Method 2 : Using Command Inside View <Window x:Class="PrismDemo.Views.MainWindow"         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.openxmlf