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
Attachment:
App1_b4404a45.zip