Here’s this month’s edition of WPF Tips & Tricks.
Should you have questions regarding the support tickets referenced in this post, feel free to comment below. We’ll be happy to follow-up.
Data Grid
- How to display multiline text in the WPF Grid control’s header (T906783)
- How to prevent the expansion of the first group when the WPF Grid Control is bound to CollectionView (T906810)
- How to specify custom items for the ExcelSmart filter popup (T914991)
One way to customize a column’s filter dropdown is to subscribe to its TableView’s ShowFilterPopup event. You can also handle this event to modify its Excel-style drop-down filter as follows:
- How to highlight Grid Control cells based on values in a dictionary (T906148)
Conditional Formatting includes a large number of built-in function operators. It also allows you to create your own custom function operators for specific usage scenarios:
public class IsInDirtyDictionary : ICustomFunctionOperator { public object Evaluate(params object[] operands) { if (operands[1] is Dictionary<string, bool> && operands[0] != null && ((Dictionary<string, bool>)operands[1]).ContainsKey(operands[0].ToString())) { return ((Dictionary<string, bool>)operands[1])[operands[0].ToString()]; } return false; } public string Name { get { return "IsInDirtyDictionary"; } } public Type ResultType(params Type[] operands) { return typeof(bool); } }
public MainWindow() { InitializeComponent(); CriteriaOperator.RegisterCustomFunction(new IsInDirtyDictionary()); }
<dxg:FormatCondition Expression="IsInDirtyDictionary('Name', [Dirty])" FieldName="Name"> <dxg:FormatCondition.Format> <dx:Format Background="Red" /> </dxg:FormatCondition.Format> </dxg:FormatCondition>
- WPF Grid Control – pasting more than 242 columns (T913311)
Tree List
- How to display items from different collections as children for the same parent node (T905175)
- How to draw horizontal lines between nodes at different levels (T906515)
- How to hide seconds in DateEdit with DateEditNavigatorWithTimePickerStyleSettings (T833668)
If using v20.1, use our built-in
TimePicker.VisibleMaskParts
property to configure visible mask segments.<Window.Resources> <Style TargetType="dxe:TimePicker"> <Setter Property="VisibleMaskParts" Value="Hours,Minutes" /> </Style> </Window.Resources>
Editors
- How to use AutoSuggestEdit as a cell editor in a column bound to a complex property type (T904440)
- How to implement an editor from TimePicker without the clock (T905936)
- How to disable drop-down items in ComboBoxEdit with RadioComboBoxStyleSettings (T913330)
To customize drop-down items (when you’ve set the
StyleSettings
property), use the StyleSettings.ItemContainerStyle property. Please note that your custom style must inherit built-in item styles as follows:<dxe:ComboBoxEdit.StyleSettings> <dxe:RadioComboBoxStyleSettings> <dxe:RadioComboBoxStyleSettings.ItemContainerStyle> <Style xmlns:dxet="http://schemas.devexpress.com/winfx/2008/xaml/editors/themekeys" BasedOn="{StaticResource {dxet:EditorListBoxThemeKey ResourceKey=RadioButtonItemStyle}}" TargetType="{x:Type dxe:ComboBoxEditItem}"> </Style> </dxe:RadioComboBoxStyleSettings.ItemContainerStyle> </dxe:RadioComboBoxStyleSettings> </dxe:ComboBoxEdit.StyleSettings>
- How to use FilterEditorControl in standalone mode without a data control - with a filtering context (T913671)
Other Controls
- How to change date display format in Month View cells (T906412)
MonthCellControl visualizes a Month View cell. It includes a set of properties designed to specify a custom display format for dates displayed within cells. Use a custom
CellStyle
to specify these properties in your Scheduler control.<dxsch:MonthView.CellStyle> <Style TargetType="dxschv:MonthCellControl"> <Setter Property="DayStringFormat" Value="{}{0:MM/dd}"/> <Setter Property="FirstDayOfMonthStringFormat" Value="{}{0:MM/dd}"/> <Setter Property="FirstDayOfYearStringFormat" Value="{}{0:MM/dd}"/> </Style> </dxsch:MonthView.CellStyle>
- How to align the title and description in our WPF Property Grid control's Description Panel (T915080)
If you’ve come across a WPF-related support ticket you’d like to share with the rest of the DevExpress community, feel free to share the link in the comments section.