我有以下课程:
public class ErrorMessage
{
public enum Severity { Error, Warning}
public ErrorMessage(Severity severity, string description)
{
this.severity = severity;
this.description = description;
}
public Severity severity { get; set; }
public string description { get; set; }
public string background
{
get
{
switch (this.severity)
{
case Severity.Error: return "Red";
case Severity.Warning: return "Yellow";
default: throw new Exception("severity out of bounds");
}
}
}
}
我将 ErrorMessage 列表绑定到 Telerik GridViewDataControl WPF 控件:
<telerik:GridViewDataControl Margin="0" telerik:StyleManager.Theme="Office_Silver" Name="errorsGridView" AutoGenerateColumns="False" CanUserSortColumns="False" IsFilteringAllowed="False" ShowGroupPanel="False">
<telerik:GridViewDataControl.Columns>
<telerik:GridViewDataColumn IsReadOnly="True" UniqueName="{x:Null}" Header="Severity" DataMemberBinding="{Binding severity}" />
<telerik:GridViewDataColumn IsReadOnly="True" UniqueName="{x:Null}" Header="Description" DataMemberBinding="{Binding description}" />
</telerik:GridViewDataControl.Columns>
</telerik:GridViewDataControl>
我希望每行的整个背景颜色都由 ErrorMessage.background 属性绑定。我该怎么做呢?提前致谢!