Posts

Showing posts with the label WPF controls

Label vs TextBlock in WPF: What's the Difference and When to Use Each.

 In this Blog, we will be discussing the difference between the Label and TextBlock controls in WPF. These two controls are often used to display text in a WPF application, but they have some key differences that you should be aware of when deciding which one to use in your projects. First, let's take a look at the label control. The label control is used to display a single line of text that is typically associated with another control, such as a textbox or a button. The label control is often used to provide a description or a prompt for the user. The label control is also typically used to display a static text and can't be used for editing text. <Label Content="Enter your name:" /> This will create a label with the text "Enter your name:" displayed on the screen. On the other hand, the textblock control is used to display multiple lines of text. It's more flexible than the label control and can be used to display formatted text, such as bol

Pagination of DataGrid in WPF using MVVM

Image
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

How to apply theme and color in wpf Metro window application

Image
In this example i am using Prism,unity and MahApps make sure you are also using same otherwise you will not get PrismApplication,BindableBase and MetroWindow .   MainWindow.xaml  <metro:MetroWindow x:Class="WpfApplication.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:WpfApplication"              mc:Ignorable="d"              xmlns:metro="http://metro.mahapps.com/winfx/xaml/controls"              xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"              Title="Welcome To Metro ui with Prism Unity">      <