| |
TextBox Style |
|
![TextBox Style](../../CSharpImages/WPF-TextBoxStyle.PNG) |
<Window x:Class="WpfApplication1.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="WPF" Height="220" Width="300">
<Window.Resources>
<Style x:Key="BaseControlStyle"
TargetType="{x:Type Control}">
<Setter Property="FontFamily" Value="Tahoma" />
<Setter Property="FontSize" Value="24pt"/>
<Setter Property="Margin" Value="4" />
</Style>
<Style TargetType="{x:Type Button}"
BasedOn="{StaticResource BaseControlStyle}">
<Setter Property="FontWeight" Value="Bold" />
</Style>
<Style TargetType="{x:Type CheckBox}"
BasedOn="{StaticResource BaseControlStyle}">
</Style>
<Style TargetType="{x:Type TextBox}"
BasedOn="{StaticResource BaseControlStyle}">
</Style>
</Window.Resources>
<Grid>
<StackPanel>
<CheckBox>CheckBox</CheckBox>
<TextBox>TextBox</TextBox>
<Button>Button</Button>
<Button FontWeight="Light">Button with overridden style</Button>
<TextBlock>TextBlock</TextBlock>
<ComboBox>ComboBox</ComboBox>
</StackPanel>
</Grid>
</Window>
|
|
|
Related examples in the same category |
1. | Bind TextBlock to TextBox | | ![Bind TextBlock to TextBox](../../CSharpImages/WPF-BindTextBlockToTextBox.PNG) | 2. | TextBox focus listener | | ![TextBox focus listener](../../CSharpImages/WPF-TextBoxFocusListener.PNG) | 3. | TextBox with custom ErrorTemplate and ToolTip | | ![TextBox with custom ErrorTemplate and ToolTip](../../CSharpImages/WPF-TextBoxWithCustomErrorTemplateAndToolTip.PNG) | 4. | TextBox uses the ExceptionValidationRule and UpdateSourceExceptionFilter handler | | ![TextBox uses the ExceptionValidationRule and UpdateSourceExceptionFilter handler](../../CSharpImages/WPF-TextBoxUsesTheExceptionValidationRuleAndUpdateSourceExceptionFilterHandler.PNG) | 5. | TextBox with UpdateSourceExceptionFilter handler | | ![TextBox with UpdateSourceExceptionFilter handler](../../CSharpImages/WPF-TextBoxWithUpdateSourceExceptionFilterHandler.PNG) | 6. | TextBox with default ErrorTemplate | | ![TextBox with default ErrorTemplate](../../CSharpImages/WPF-TextBoxWithDefaultErrorTemplate.PNG) | 7. | TextBox MouseLeftButtonDown action and PreviewMouseLeftButtonDown action | | ![TextBox MouseLeftButtonDown action and PreviewMouseLeftButtonDown action](../../CSharpImages/WPF-TextBoxMouseLeftButtonDownActionAndPreviewMouseLeftButtonDownAction.PNG) | 8. | Assign your own class to DataContent and bind to TextBox | | ![Assign your own class to DataContent and bind to TextBox](../../CSharpImages/WPF-AssignYourOwnClassToDataContentAndBindToTextBox.PNG) | 9. | Listen to TextBox text changed event | | ![Listen to TextBox text changed event](../../CSharpImages/WPF-ListenToTextBoxTextChangedEvent.PNG) | 10. | Handler for the PreviewKeyDown event on the TextBox | | ![Handler for the PreviewKeyDown event on the TextBox](../../CSharpImages/WPF-HandlerForThePreviewKeyDownEventOnTheTextBox.PNG) | 11. | TextBox: set text, select all, clear, prepend, insert, append, cut, paste, undo | | ![TextBox: set text, select all, clear, prepend, insert, append, cut, paste, undo](../../CSharpImages/WPF-TextBoxSetTextSelectAllClearPrependInsertAppendCutPasteUndo.PNG) | 12. | Set TextBox to editable | | ![Set TextBox to editable](../../CSharpImages/WPF-SetTextBoxToEditable.PNG) | 13. | TextBox text changed event | | ![TextBox text changed event](../../CSharpImages/WPF-TextBoxTextChangedEvent.PNG) | 14. | TextBox PreviewKeyDown | | ![TextBox PreviewKeyDown](../../CSharpImages/WPF-TextBoxPreviewKeyDown.PNG) | 15. | TextBox KeyDown | | ![TextBox KeyDown](../../CSharpImages/WPF-TextBoxKeyDown.PNG) | 16. | TextBox PreviewKeyUp | | ![TextBox PreviewKeyUp](../../CSharpImages/WPF-TextBoxPreviewKeyUp.PNG) | 17. | TextBox KeyUp | | ![TextBox KeyUp](../../CSharpImages/WPF-TextBoxKeyUp.PNG) | 18. | TextBox TextInput | | ![TextBox TextInput](../../CSharpImages/WPF-TextBoxTextInput.PNG) | 19. | TextBox PreviewTextInput | | ![TextBox PreviewTextInput](../../CSharpImages/WPF-TextBoxPreviewTextInput.PNG) | 20. | Scroll TextBox | | ![Scroll TextBox](../../CSharpImages/WPF-ScrollTextBox.PNG) | 21. | TextBox TextChanged event | | ![TextBox TextChanged event](../../CSharpImages/WPF-TextBoxTextChangedEvent.PNG) | 22. | Use Dictionary to record which textbox has been changed and not saved | | ![Use Dictionary to record which textbox has been changed and not saved](../../CSharpImages/WPF-UseDictionaryToRecordWhichTextboxHasBeenChangedAndNotSaved.PNG) | 23. | Set TextBox ContextMenu to null | | ![Set TextBox ContextMenu to null](../../CSharpImages/WPF-SetTextBoxContextMenuToNull.PNG) | 24. | TextBox Selection start, end and selected text | | ![TextBox Selection start, end and selected text](../../CSharpImages/WPF-TextBoxSelectionStartEndAndSelectedText.PNG) | 25. | Scrollable TextBox Column | | ![Scrollable TextBox Column](../../CSharpImages/WPF-ScrollableTextBoxColumn.PNG) | 26. | TextBox PreviewKeyDown, PreviewKeyUp, PreviewTextInput, KeyDown, KeyUp and TextChanged events | | ![TextBox PreviewKeyDown, PreviewKeyUp, PreviewTextInput, KeyDown, KeyUp and TextChanged events](../../CSharpImages/WPF-TextBoxPreviewKeyDownPreviewKeyUpPreviewTextInputKeyDownKeyUpAndTextChangedEvents.PNG) | 27. | Check Spelling Error | | ![Check Spelling Error](../../CSharpImages/WPF-CheckSpellingError.PNG) |
|