У меня проблемы с использованием {x:Bind}
, и конвертер создает необработанное исключение.
C# Код
public class ProviderSpecialtyConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string language)
{
string specialty = "";
try
{
specialty = value.ToString();
}
catch { }
switch (specialty)
{
case "276":
return "General Dentists";
case "277":
return "Hygienists";
default:
return value;
}
}
public object ConvertBack(object value, Type targetType, object parameter, string language)
{
throw new NotSupportedException();
}
}
XAML
<Custom:DataGrid.RowGroupHeaderStyles>
<Style TargetType="Custom:DataGridRowGroupHeader">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Custom:DataGridRowGroupHeader">
<Border BorderBrush="{StaticResource SystemControlBackgroundChromeWhiteRevealBorderBrush}" BorderThickness="2" Background="{ThemeResource GrayAcrylicInAppLuminosity}" Padding="5">
<StackPanel Orientation="Horizontal">
<FontIcon Glyph="" FontSize="10"/>
<TextBlock Text="{x:Bind PropertyValue, Converter={CustomResource ProviderSpecialtyConverter}}" FontWeight="Normal" FontSize="12" Margin="10,0,0,0" HorizontalAlignment="Left" VerticalAlignment="Center" x:Name="GroupProvider"/>
<TextBlock Text="{x:Bind CollectionViewGroup.GroupItems.Count}" FontWeight="Normal" FontStyle="Italic" FontSize="12" Margin="10,0,0,0" HorizontalAlignment="Right" VerticalAlignment="Center"/>
<TextBlock x:Name="GroupNetProduction" Text="{x:Bind PropertyName}" FontWeight="Normal" FontStyle="Italic" FontSize="12" Margin="10,0,0,0" HorizontalAlignment="Right" VerticalAlignment="Center"/>
</StackPanel>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Custom:DataGrid.RowGroupHeaderStyles>
Не уверен, почему это происходит. Использование {Binding}
не вызывает того же исключения, но {Binding}
не может получить доступ к PropertyValue группы.