Ranjit Menon

Ranjit Menon

  • NA
  • 8
  • 7.7k

WPF trim property value before binding

Apr 8 2014 12:28 PM
I have bound the datagrid Type column with the property called Vehile of the dataobject. The value of the property for example is InventoryService.Car, InventoryService.Boat etc. I need to display only Car  or Boat and trim the remaining part that is InventoryService. How do I achieve that. My current code is as follows

 <DataGrid.Columns>
                        <DataGridTextColumn Header="Type" Binding="{Binding Path=Vehicle}" />
                        <DataGridTextColumn Header="Make" Binding="{Binding Path=Vehicle.Make}" />
                        <DataGridTextColumn Header="Model" Binding="{Binding Path=Vehicle.Model}" />
                        <DataGridTextColumn Header="No of Wheels" Binding="{Binding Path=Vehicle.NumberOfWheels}"/>
                        <DataGridTemplateColumn Header="Road Vechile">
                            <DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <CheckBox  IsChecked="{Binding Path=Vehicle.Environment,Mode=OneWay }"/>
                                </DataTemplate>
                            </DataGridTemplateColumn.CellTemplate>
                        </DataGridTemplateColumn>
                    </DataGrid.Columns>

Answers (1)