Search This Blog

Showing posts with label WPF. Show all posts
Showing posts with label WPF. Show all posts

Wednesday, May 8, 2019

WPF Calendar SelectedDates

WPF->Calendar

Add multiple selected dates to WPF Calendar.

<Grid>
   <Calendar x:Name="calendar" />

</Grid>

calendar.SelectionMode = CalendarSelectionMode.MultipleRange; 
calendar.SelectedDates.Add(new DateTime(2020, 1, 1)); 
calendar.SelectedDates.Add(new DateTime(2020, 1, 2));


Wednesday, December 14, 2016

Set DataGrid DataGridRow Background color WPF

WPF > DataGrid > DataGridRow > Background


<DataGrid.RowStyle>
  <Style TargetType="DataGridRow">
    <Style.Triggers>
      <DataTrigger Binding="{Binding IsValid}" Value="true">
        <Setter Property="Background" Value="Green"></Setter>
      </DataTrigger>
      <DataTrigger Binding="{Binding IsValid}" Value="false">
        <Setter Property="Background" Value="Red"></Setter>
      </DataTrigger>
    </Style.Triggers>
  </Style>
</DataGrid.RowStyle>

Wednesday, May 21, 2014

Get tree visual elements WPF

WPFWindows > MediaVisualTreeHelper 

VisualTreeHelper provides methods that perform

tasks involving nodes in a visual tree.


Example:

Get tree visual elements for user control


FrameworkElement fe = (FrameworkElement)YourControl;
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(fe); i++)
{
   Grid childVisual = (Grid)VisualTreeHelper.GetChild(fe, i);
   childVisual.Width = sp.ActualWidth;
}

Tuesday, October 22, 2013

What is Windows Presentation Foundation (WPF) ?

Windows > Controls > Binding > Printing > Resources

Windows Presentation Foundation (WPF) is a UI framework that creates rich, interactive client applications.
WPF combines application UIs, 2D and 3D graphics, documents and multimedia into one single framework.
The WPF development platform supports a broad set of application development features, including an application model, resources, controls, graphics, layout, data binding, documents, and security.
It is a subset of the .NET. Its vector based rendering engine uses hardware acceleration of modern graphic cards. This makes the UI faster, scalable and resolution independent.

WPF uses the Extensible Application Markup Language (XAML) to provide a declarative model for application programming.

Examples:

 

Create a simple ‘Hello World’ WPF application

WPF > First application

Create a simple ‘Hello World’ WPF application

Go to menu File - > New Project and then Visual C# -> Windows -> WPF Application.

 
Visual studio automatically creates the project and adds some files: MainWindow.xaml and MainWindow.xaml.cs
Double click on MainWindow.xaml and from Toolbox window drag a button and a label. Name label “lblTtitle”.

 
Double click button and add the following code: lblTitle.Content = "Hello World!";

 
Press F5 to run the application