Here BindableBase class i used from the prism if you are not using Prism you will not get BindableBase class you have to implement INotifyPropertyChanged
public class CharInfo : BindableBase
{
private string _charecter;
public string Charecter
{
get { return _charecter; }
set
{
_charecter = value;
SetProperty(ref _charecter, value);
}
}
private int _position;
public int Position
{
get { return _position; }
set
{
_position = value;
SetProperty(ref _position, value);
}
}
}
Add these Property, Command and method to ViewModel
private ObservableCollection<CharInfo> matchedInfo = new ObservableCollection<CharInfo>();
public ObservableCollection<CharInfo> MatchedInfo { get => matchedInfo; set => SetProperty(ref matchedInfo, value); }
private string text;
public string Text { get => text; set => SetProperty(ref text, value); }
private string charToMatch;
public string CharToMatch { get => charToMatch; set => SetProperty(ref charToMatch, value); }
private ICommand matchCharCommand;
public ICommand MatchCharCommand
{
get
{
if (matchCharCommand == null)
{
matchCharCommand = new DelegateCommand(MatchChar);
}
return matchCharCommand;
}
}
private void MatchChar()
{
MatchedInfo.Clear();
if (!string.IsNullOrEmpty(Text) && !string.IsNullOrEmpty(CharToMatch))
{
for (int i = 0, pos = -1; i < Text.Length;)
{
pos = Text.IndexOf(CharToMatch, pos + 1);
if (pos < 0)
break;
MatchedInfo.Add(new CharInfo { Charecter = charToMatch, Position = pos });
In this Post i will explain the pagination using the MVVM pattern. Lets first create the View with DataGrid and pagination control with First, Previous, Next and Last buttons and we will also have the number of record per page to be displayed in DataGrid option which is ComboBox and in this DataGrid i will load data from CSV file. View I will create the view with DataGrid like this And in this DataGrid i will load data from CSV file <Window x:Class="CURD.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:CURD.Views" mc:Ignorable="d" Title="EmployeeDetails" xmlns:sys="clr-namespace:Syste
In this post, we'll walk you through the step-by-step process of establishing a connection between your WPF application and a SQL Server database. By the end of this tutorial, you'll have a solid understanding of how to harness the power of SQL databases to manage your application's data efficiently. Let's get started! Step 1: Setting Up Your Project Open Visual Studio: Launch Visual Studio and create a new WPF project. <Window x:Class="WpfTutorialSeries.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:WpfTutorialSeries" mc:Ignorable="d" Title="Registration" SizeToContent="WidthAndHeight&qu
Comments
Post a Comment