.


:




:

































 

 

 

 





WPF. . , , . WPF , ; , .

. . , , - , , . , Worde , , .

, WPF , . , WPF , : New, Exit, Cut, Copy Save. ApplicationCommands. , , , , . , , , , , , .

, , , , CanExecute Execute. CanExecute, , , - . CanExecute , Execute.
*.cs . :

void canExecute_Save(object sender, CanExecuteRoutedEventArgs e) { } void execute_Save(object sender, ExecutedRoutedEventArgs e) { }


, . MainWindow :

public MainWindow() { InitializeComponent(); CommandBinding saveCommand = new CommandBinding(ApplicationCommands.Save, execute_Save, canExecute_Save); CommandBindings.Add(saveCommand); }


CommandBindings, , , CommandBindings. CommandBinding, , (ApplicationCommands.Save), , Execute CanExecute.
, Xaml :

<TextBox Margin="4" VerticalScrollBarVisibility="Auto" Name="inputTextBox" />


, cs-.
canExecute:

void canExecute_Save(object sender, CanExecuteRoutedEventArgs e) { if (inputTextBox.Text.Trim().Length > 0) e.CanExecute = true; else e.CanExecute = false; }


e. CanExecute , CanExecute , , , .
, -, . Trim .
Execute :

void execute_Save(object sender, ExecutedRoutedEventArgs e) { System.IO.File.WriteAllText("textFile.txt", inputTextBox.Text); MessageBox.Show(" "); }


, MessageBox, .
, , . Xaml, , . Command, , . Save. , , , , ToolTip=, :

<Button ToolTip="" Command="Save" >


, Command Save, , , , CanExecute false. .1. .



2. .

F5, , . , . , , CanExecute.

.


WPF , . , . , . cs , WPF cs , .
, Slider , . Xaml DockPanel, :

<DockPanel Margin="5" Grid.Row="1" HorizontalAlignment="Right" > <Label Content=" :" ></Label> <Slider Margin="4" MinWidth="100" Name="fontSlider" Maximum="100" Minimum="12" ></Slider> <Button Style="{StaticResource okButtonStyle}" Content="Ok" /> </DockPanel>


, 100 . Xaml:

<TextBox Margin="4" VerticalScrollBarVisibility="Auto" Name="inputTextBox" FontSize="{Binding ElementName=fontSlider, Path=Value, UpdateSourceTrigger=PropertyChanged}" />


, , FontSize , ElementName , , Path , , UpdateSourceTrigger , , , .
, - , Value (.2.)



2. .

WPF, . 5 , , , , , WPF /, . , , WPF . , WPF , Net.Frameworka WPF, WinForms, Net.Framework, , . , WinForms , , WPF.
, , , StepByStep, .

 

 





:


: 2016-10-06; !; : 380 |


:

:

, .
==> ...

1757 - | 1578 -


© 2015-2024 lektsii.org - -

: 0.011 .