As always, we hope you are doing well in this difficult time period. If we can be of service, please contact us at your convenience.
In this month’s edition of our WPF Tips & Tricks post, we decided to create a couple of WPF Grid-related examples – examples that address important usage scenarios. We also summarized a list of interesting support tickets answered throughout the previous month. Should you have any questions about our WPF Grid examples or the support tickets listed herein, feel free to comment below.
WPF Data Grid - Examples
Our WPF Data Grid control ships with a series of properties that help define custom row/cell styles and cell templates. (for more information, please refer to the following help topics: CellStyle, RowStyle, CellTemplate, CellDisplayTemplate, CellEditTemplate). The following samples illustrate how you can build binding paths for elements that rely on these styles and templates:
- How to build binding paths within WPF Grid control cells (T925591)
- How to build binding paths within WPF Grid control rows (T925592)
Note: Tools like Snoop help show the runtime visual tree and objects within DataContext (and can help build binding paths).
To review best practices related to synchronous and asynchronous CRUD operations (in a data bound WPF Grid control), please refer to projects listed in this example:
TICKETS:
WPF Data Grid
- How to highlight the header of a focused column (T921146)
Define an implicit style for
BaseGridHeader
. Declare a newDataTrigger
to check whether the column is stored in GridControl.CurrentColumn and change its background color. With DXBinding, you will not need a custom converter:<Style TargetType="dxg:BaseGridHeader"> <Style.Triggers> <DataTrigger Binding="{DXBinding Expr='@c == @c.View.Grid.CurrentColumn'}" Value="True"> <Setter Property="Background" Value="#FFCDE6F7"/> </DataTrigger> </Style.Triggers> </Style>
- WPF TreeList control - How to prevent dragging inside a node and increase the target area to drag before/after a node (T924612)
- How to display more than 10000 filter items in the Column Filter Dropdown (T264950)
- How to display different detail tabs across different master rows (T919152)
You can display different detail descriptors based on underlying data in master rows. For more information, refer to the following help topic: Data Dependent Details.
- How to focus the first cell when New Item Row is activated (T918830)
- How to use Ctrl+S for the Update button when the Edit Entire Row feature is enabled (T923978)
Use the KeyToCommand class with the Ctrl+S
KeyGesture
and bind itsCommand
to the TableView'sUpdateRow
command (see: TableViewCommands.UpdateRow Property):xmlns:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm" xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid" ... <dxg:TableView ShowUpdateRowButtons="OnCellEditorOpen" x:Name="view"> <dxmvvm:Interaction.Behaviors> <dxmvvm:KeyToCommand KeyGesture="Ctrl+S" Command="{Binding ElementName=view, Path=Commands.UpdateRow}"/> </dxmvvm:Interaction.Behaviors> </dxg:TableView>
- How to use grouping in a WPF Grid control bound to a ListCollectionView (T918354)
- A Boolean column requires three clicks to change its values when TableView.AllowDragDrop is True (T925718)
WPF Editors
- How to bind a DX editor to a Nullable property (T925300)
- How to display a button within ButtonEdit on mouse over or when the editor is focused (T925205)
Change the
Visibility
property of your button based on values for the editor’sIsKeyboardFocusWithin
andIsMouseOver
properties:<dxe:ButtonEdit x:Name="editor" ...> <dxe:ButtonEdit.Buttons> <dxe:ButtonInfo Content="Test" Visibility="{DXBinding Expr='@e(editor).IsKeyboardFocusWithin or @e(editor).IsMouseOver ? $Visibility.Visible : $Visibility.Collapsed'}"/> </dxe:ButtonEdit.Buttons> </dxe:ButtonEdit>
To learn more, please refer to the following help topic: DXBinding.
- How to select an AutoSuggestEdit item that remains in the source after search (T922849)
- How to support different formats for TrackBarEdit tick values (T922489)
- How to specify the number of characters visible in cells with a password box (T916236)
- How to extend a DateEdit's popup (T920390)
Use the
DateNavigatorCalendarControl.CellSize
property to change the size of an individual calendar segment. This will also increase popup size:xmlns:dxei="http://schemas.devexpress.com/winfx/2008/xaml/editors/internal" ... <Window.Resources> <Style TargetType="dxei:DateNavigatorCalendarControl"> <Setter Property="CellSize" Value="60,40" /> </Style> </Window.Resources>
WPF Bars
WPF Scheduler
- How to use ReminderItems in a Scheduler bound to a database (T922985)
- Scheduler defined inside ScrollViewer shifts newly added appointments (T922570)
WPF Charting and Maps
- How to programmatically set AxisLabelResolveOverlappingOptions for X/Y-axis labels (T920955)
- How to make the WPF Chart Control pane area transparent (T916519)
Other Controls
- Localization for .NET Core 3.1 WPF applications with DevExpress Localization Service (T924211)
You can use satellite assemblies generated via our Localization Service in your .NET Core WPF applications. Note: you’ll need to initialize
AssemblyLoadContext.Default
here:_ = System.Runtime.Loader.AssemblyLoadContext.Default;
Initialization is required because of the following issue: AssemblyLoadContext.Default is uninitialized – Localized resources from culture specific RESX files are ignored.
- How to change the foreground for specific text segments in a LayoutItem's Label (T920376)
- Bindings do not work for DX controls defined in a custom ContentTemplate (T920733)
- How to open Theme selector from TileNavPane (T919989)
Your Feedback Matters
Your thoughts and comments are important. If you find these blog posts of value, please post a note below. If you feel they can be improved, please share your recommendations with us. Thank you for your continued support.