      Windows Presentation Foundation
  

  


           Windows Presentation Foundation (WPF),     .NET,    3.0.        19     Microsoft Visual Studio 2015,     WPF.     .    48  ,     .   ,     02.03.02     .





.. , . . 

      Windows Presentation Foundation








            Windows Presentation Foundation (WPF),    .NET,    3.0.          ,         Windows Forms,      .NET.      ,    Windows Forms ( ,   ),  WPF    ,   ,       ,          ,      ,    .

    WPF           ,        XML-,          XAML (eXtensible Application Markup Language).  ,            .

     WPF      ,    ,     .    WPF     ,         ,      ,     ,        .

     Windows Forms   ,    DirectX            .     -    (  ),          .

       WPF    WPF-,      Microsoft Visual Studio ( 20082015).     ,     Windows Forms,   ,     xaml-,    .   (    )     ,   ,     ,      xaml-.

     WPF          ,    .NET,                      .

 , ,   .     WPF    ,       .       .   ,    ,     [79] (            23 ).              [7],      (      )      .    , , ,     .

       .   ,       WPF,       ,         ,   .          ,         WPF.     ,    .        WPF     Windows Forms.         ,     ,        .                        VCL   Borland Delphi [1, 2]   WPF   Windows Forms  .NET [3].

    19 .       .        WPF:    WPF-,   xaml-,   ,      ( EVENTS),      WPF-,    ,    ( WINDOWS),    ,   ( CALC),   WPF- ( CLOCK),   ,      ( TEXTBOXES),   ( MOUSE),   Drag & Drop ( ZOO),     ,   ,    WPF  Windows Forms ( CURSORS).

        TEXTEDIT,   5  ( ).          ,        :       ( 1  2),   ( 3),   ( 4),   ( 5).  ,   1        (, ,     ),        WPF;  2   ,     WPF;  3     ;   4  5         ,  ,       .

   ,     WPF          TrackBar ( COLORS),           ( LISTBOXES),       ( CHECKBOXES),    ,      ,   GridSplitter  Image,   Windows     ( IMGVIEW),           ( TRIGFUNC),       ( HTOWERS).

    48  ,   5 .     ;          ,          ,       Drag & Drop,     ,  ,           .              .

        WPF,     ,             .

,         .    C#,    XML,  ,   ,            .        [5],      C#     .NET,    [4],       (   ,      ),    C#   LINQ,     LINQ to XML.

     Microsoft Visual Studio 2015,             (   2008).     C#,     6.0     Visual Studio  2015  ,           .

       xaml-     EVENTS.             WPF-.




1.: EVENTS






. 1.   EVENTS






1.1.    WPF-


        Visual Studio,   File | New | Project (Ctrl+Shift+N),    New Project      Visual C#,       WPF Application,    Name    (   EVENTS),     Location  ,      .    Create directory for solution,        (      ,     ;        ).       OK.

     EVENTS,     ,      EVENTS.sln,   EVENTS.csproj,        ,  :  MainWindow,    ,   App,   ,           .

     :  xaml,        ,    cs (     xaml),       C#.    xaml (xaml-)   XML (eXtensible Markup Language    ).  XAML (   ) ,      XML: eXtensible Application Markup Language      .

  ,    App    Visual Studio 2015.

App.xaml:








App.xaml.cs:








   ,   App     Application,     cs-      App   (   ,     App  cs-   partial, ,         ).   (    ,  )     EVENTS,    .

   xaml-     ,     XML-.            XML-,        XML-   .     ;      <_ _>,     </_>.      ,       /  ()  (   XML-,     ,    xaml-   ).       .     ,           <_ _ />.      : _="_";      (  ).        ,           .    ;   ,       , ,  . (), - ()  _ ()     ,    .     .          ,      (  App.xaml    : xmlns:x  xmlns:local).  XML-    XML-  ,    (  App.xaml   Application).

     App,    xaml-,  ,        ,       .   StartupUri  Application,    MainWindow.xaml.       Application.    ,        xaml-,     Properties,          xaml- (     xaml-,  cs-,   Properties  ).

      xaml-      xaml-       .  Properties    ,        .  xaml-    ,          .    xaml-  ,    Properties     ,     .

     xaml-           cs- .

 App    .           ,    App.





             xaml-  cs-.  xaml-        2     (      ,      xaml-    );            ,          4     .  cs-  :       4  (     Visual Studio),            2 .


 ,    MainWindow;          ( ) .

MainWindow.xaml:








MainWindow.xaml.cs:













     xaml-       ,   Title,        .

   xaml-           .  ,    WPF-      ,    ,   Windows Forms.    ,       WPF-     ,     ,     ,         (  ).  ,      ,   ,     ,   xaml-      ,     .          .

   ,           Grid      ,          .  ,   MainWindow   : Title, Height  Width.        Properties (    ,    xaml-  ,      ,       ).       Properties    ,       ,  ,       .  ,    ,    ,     ,    ,      . ,       Height       : Height, MaxHeight  MinHeight.

  MainWindow.xaml.cs     MainWindow,    ,     InitializeComponent,      .           ,          .





 XML-  xaml-      (    ),     (     -). XML-      :  -,       ,  -,     . (-   ,        ).

 ,     WPF   ,     xaml-,         - (     Content; ,     MainWindow.xaml  Content  Window   Grid).        .   -  ,     - (     Children,     -, ,  Grid       Canvas).





1.2.      


      WPF- ,           .       Grid    Canvas.        ,  ,       Button.

     :   ,               Toolbox,      xaml-.

  .

       Grid,    . ,     Grid,     xaml- (      <Grid>)    Properties (    ).      ,   Delete.    ,       Window  xaml-       <Window  />,       .

      Canvas.      Toolbox,        Visual Studio   .    ,         View | Toolbox (Ctrl+W, X).        Toolbox         ,     . ,       Can,       Canvas.      ,       All WPF Controls.    Canvas      .    Canvas          xaml- (      Window  xaml-       <Window>  </Window>):








         xaml-,  ,      .   xaml-    .

      . 2.






. 2.      Canvas



,       Canvas. ,       .     ,     xaml-    Canvas (    ):








      . 3.






. 3.       Canvas



 ,     -       Toolbox,    ,     .

    Canvas  Button,      Toolbox    .              (       ,    10         , . 4).






. 4.      Button



 xaml-   :








 ,    Canvas      ,        .

 ,     Button.    x:Name  ,          cs-.         MainWindow.    ,   Canvas    .  ,    MainWindow         Canvas.    ,      (    ,    Name  ,    xaml-).

 Content   .     Content     ,    .  ,      ,  ,   ,      .     WPF-   ,    . ,   ,    ,    (       ., ,  ZOO, . 7.7).

     ,       Height (  Width ).   Height ,        ,      .       Width,         ,    Width ,  ,        .

      Windows Forms,   WPF    Top  Left,  ,    .    ,        WPF    (     ,       ).        Top  Left,    Canvas.           Canvas,          .               ,   WPF        (dependency properties).     WPF   ,        ,   WPF, ,      .        (attached properties), ,     ,    .  Top  Left  Canvas     .

   Canvas     xaml-.         ,    .

,         xaml-   :








     ,      xaml-,             Toolbox,        ,   xaml-.

  xaml-:       ,      ,     button1 (         ).  ,     WindowStartupLocation,    CenterScreen (         ):








       Properties,        xaml-.  ,      xaml-   ,             ,    ,      ,   Tab,    xaml-       ,     ="",       ,      ,      (   ,   WindowStartupLocation).

    ,             ,       xaml-,         .  ( )      ,   ,      .             C#.





  xaml-    ,        .

(1)     ,    ,            ,     .

. ,      (    |):







    >,      ( | -    ):







(2)          / (     ),        xaml- (      ,   ,     ,    ).

.   ,    ,      







   /,     :







.    (     F5)          (. 5).






. 5.   EVENTS ( )



         ,         ,     (, , ,    ).





  WPF-   Visual Studio   Debug          (. 6).





. 6.      XAML





      ,    .       Tools | Options,     Options   Debugging       Enable UI Debugging Tools for XAML.





1.3.    


         button1.      :

1)      button1;

2)   Properties      ,      : 


;

3)        Click          ;

4)        MainWindow.xaml.cs,        MainWindow    Click   button1:








5)     ,       button1;      :








,        xaml-:








    Click  xaml-  button1_Click     Click  button1 (     button1_Click     ,       ).

            Windows Forms.   WPF-       ,     Properties.          xaml- (     Button    Click=,               )            New Event Handler    (    )    Enter.    xaml-     (   button1_Click),   cs-        ,      ,      xaml-.      ,    ,     xaml-,        New Event Handler       ,            (       ,          CALC).

  -    ,        ,       .

                xaml-       ,   ( )   :













 button1_Click      ,   ,    ,        xaml-    Click=       New Event Handler (,     cs-       ).

             Canvas (   ,      ,   ,           ):













 ,      Canvas:








.                 .             Visual Studio.





1.   WPF        ,    .        (  Properties     Background   No Brush      ).  , ,     Background  xaml-,    ,    WPF   (   Brush,     -).    ,       SolidBrush    .   ,     (TRIGFUNC  HTOWERS),     ,     LinearGradientBrush  RadialGradientBrush.

2.    ,   ,   .          ,      e: e.GetPosition.     ,  ,     .    this;  ,           . ,     WPF     -  (   1/96 )        double (      Windows Forms    -     ).

3.      Canvas_MouseDown  ,       Left  Top,       Canvas.    ,   SetLeft  SetTop           Canvas,    .    Canvas.GetLeft(c)  Canvas.GetTop(c),      Left  Top   c,    Canvas (      ,   . 1.5   ).

         SetValue,    . ,      Canvas_MouseDown    :







   ,        SetValue       Property (          ,        ).  ,     SetValue       ,      (       GetValue,         . 1.5).

4.            ActualWidth  ActualHeight.  Width  Height    ,         ,          ( ,      NaN).     ActualWidth  ActualHeight    ,      .





1.4.    


    MainWindow (  public MainWindow())   :








     button2,    Content         :


















.          ,    .     ,     ,    Ctrl.       :     ,       .  ,        ,          (  Tab)     .

.    ,        ,       ,      .    ,          ,    . , , ,      WPF  ,           .

.     button2_MouseMove:













     .      .





1.       -  ,      .     =,     ,     ,     .

2.   button2_MouseMove     Canvas,            ( r.NextDouble()       [0; 1),     5 ,          ). ,        :         .    ,   Canvas        -.

     Canvas ,        ,      Content ,  ,        as.     Canvas        FrameworkElement       ,    ,   .       Panel    FrameworkElement,      . ,     Canvas   Control  ,          ( Control ,  , ,   Content,  ).

3.     ,      button2_MouseMove ,    Ctrl.              e. ,   button2_MouseMove     ( MouseEventArgs)      (  e.GetPosition)     (, ,  e.LeftButton           MouseButtonState.Pressed  MouseButtonState.Released).         





  .


   .

   ,     (https://www.litres.ru/anna-abramyan/razrabotka-polzovatelskogo-interfeysa-na-osnove-tehnologii-w/)  .

      Visa, MasterCard, Maestro,    ,   ,     ,  PayPal, WebMoney, ., QIWI ,       .


