BoldDeskWe are launching BoldDesk on Product Hunt soon. Learn more & follow us.
Hi cho dongsik,
To wrap the text of a ComboBoxItem, you can customize the GridCellComboBoxRenderer and modify the item template of the combobox. Here is a step-by-step guide on how to achieve this:
public sealed partial class MainPage : Page { public MainPage() { this.InitializeComponent(); this.dataGrid.CellRenderers.Remove("ComboBox"); this.dataGrid.CellRenderers.Add("ComboBox", new GridCellComboBoxRendererExt()); } } public class GridCellComboBoxRendererExt : GridCellComboBoxRenderer { public GridCellComboBoxRendererExt() : base() {
}
public override void OnInitializeEditElement(DataColumnBase dataColumn, ComboBox uiElement, object dataContext) { base.OnInitializeEditElement(dataColumn, uiElement, dataContext); uiElement.ItemTemplate = Application.Current.Resources["comboboxStyle"] as DataTemplate;
} } |
App.xaml
<Application.Resources> <DataTemplate x:Key="comboboxStyle"> <TextBlock Text="{Binding}" Width="200" TextWrapping="Wrap" /> </DataTemplate> </Application.Resources> |
Before:
After:
Let us know if you need any further assistance on this.
Regards,
Sathiyathanam
Thanks
cho dongsik
We are glad that the provided response meets your requirement. Please let us know if you need further assistance. As always, we are happy to help you out.