вы можете использовать конвертер значений для него
<Grid>
<Grid.Resources>
<local:HoursToMinusConverter x:Key="HoursToMinusConverter" />
</Grid.Resources>
<DataGrid x:Name="EmployeeHours"
AutoGenerateColumns="False"
ItemsSource="{Binding EmployeeHoursLastWeek}"
Width="Auto">
<DataGrid.Columns>
<DataGridTextColumn Header="PerceptionistID"
Binding="{Binding PerceptionistID}"
Width="100" />
<DataGridTextColumn Header="Week Of"
Binding="{Binding WeekOf, StringFormat={}{0:MM/dd/yyyy}}"
Width="75" />
<DataGridTextColumn Header="Regular Hours"
Binding="{Binding WorkHours}"
Width="100" />
<DataGridTextColumn Header="PTO Hours"
Binding="{Binding PTOHours, Converter={StaticResource HoursToMinusConverter}}"
Width="100" />
<DataGridTextColumn Header="Holiday Hours"
Binding="{Binding HolidayHours, Converter={StaticResource HoursToMinusConverter}}"
Width="100" />
</DataGrid.Columns>
</DataGrid>
</Grid>
вот конвертер
public class HoursToMinusConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
if (value is int) {
return (int)value > 0 ? value.ToString() : "-";
}
return string.Empty;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) {
if (value is string) {
int intValue;
if (!int.TryParse((string)value, out intValue)) {
intValue = 0;
}
return intValue;
}
return 0;
}
}
надеюсь, это поможет