Posts

Showing posts from September, 2019

Filter DataGrid and ListView in wpf using ICollectionView

Image
EmployeeDetails.xaml <UserControl x:Class="PrismMain.Views.EmployeeDetails"         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:PrismMain.Views"         mc:Ignorable="d"        >     <Grid HorizontalAlignment="Stretch" VerticalAlignment="Top" Margin="0,50,0,0">         <Grid.RowDefinitions>             <RowDefinition Height="50"/>             <RowDefinition Height="*"/>             <RowDefinition Height="*"/>         </Grid.RowDefinitions>         <StackPanel Orientation="Horizontal" HorizontalAlignment="Right"

How to use Prism Region in WPF?

Image
Step 1: Install Prism.Core,Prism.DryIoc (You can use any IOC like Prism.Unity),Prism.Wpf. Step 2: Add the prism namespace to  MainWindow.xaml   like below                            xmlns:prism="http://prismlibrary.com/" Step 3: Add ContentControl  to  MainWindow   and initilize the RegionName <Grid>         <ContentControl prism:RegionManager.RegionName =" MainRegion "/>     </Grid> Step 4: Implement IModule  class MainModule : IModule     {         public void OnInitialized (IContainerProvider containerProvider)         {            var region= containerProvider.Resolve<IRegionManager>();             region.RegisterViewWithRegion(" MainRegion ", typeof( TabView ));            // TabView is the view  or UserControl which will inject to Region         }         public void RegisterTypes(IContainerRegistry containerRegistry)         {                   }     } Step 5: App class should inherit from PrismAppl

Is it possible not to implement interface method in implementation class?

Yes, it is indeed possible to avoid implementing interface methods in the implementation class. To achieve this, you can declare the methods you don't wish to implement as abstract within the interface. By doing so, you'll need to mark the class as abstract as well. This allows you to provide the implementation of the method in a derived class of the abstract class. Let's take an example scenario using C#: interface ITest  {         void Sum();  } abstract class SumTest : ITest  {        public abstract void Sum();  } In this code, the SumTest don't have the implementation of the Sum() method. This approach can be useful when you require a method implementation but don't want to provide it immediately. By using the abstract modifier, you're indicating that derived classes should implement this method. This flexibility is particularly helpful when you want to delay the implementation until a more appropriate time. abstract class Test : SumTest  {  

What is Abstraction in C#?

The process of defining a class by providing the necessary and essential details of an object to the outside world and hiding the unnecessary things is called abstraction in C#. In C# we can hide the member of a class by using private access modifiers. Let us understand this with a car example. As we know a car is made of many things, such as the name of the car, the color of the car, gear, breaks, steering, silencer, diesel engine, the battery of the car, engine of the car, etc. Now you want to ride a car. So to ride a car you should know function of Gear,Break and Steering you no need to know engine of the car.so here in case of abstraction we can hide engine details so to do that make engine function private inside class and all require thing what we should know make it's function public.