我的問題是關於頁面表單中的DataGrid,使用C#.NET 4.0進行編程。該應用程序用於桌面,而不是Web或Silverlight。設置顏色選擇DataGrid的整行,並在更改背景顏色後的MouseOver行爲
我改變了我們頁面的DataGrid,而不是改變背景。不幸的是,當我選擇一行時,它只會變成藍色(選擇標識的顏色)隻影響該行的列。在這些數據網格中,我留下了一些空間。我需要做的是完全選擇該行,包括該空白。
另一件改變的事情是鼠標在任何記錄上的鼠標行爲。在這個變化之後,現在這種行爲不再發生了。
任何線索我需要做什麼?
編輯:添加代碼:
我的轉換器:
public class RetornaCorFundoGrid : DependencyObject, IValueConverter
{
public static DependencyProperty CorFundoGridParameterProperty =
DependencyProperty.Register("CorFundoGridParameter", typeof(IEnumerable<Object>), typeof(RetornaCorFundoGrid));
public IEnumerable<Object> CorFundoGridParameter
{
get { return ((IEnumerable<Object>)GetValue(CorFundoGridParameterProperty)); }
set { SetValue(CorFundoGridParameterProperty, value); }
}
public object Convert(Object value, Type targetType, object parameter, CultureInfo culture)
{
try
{
if (System.Convert.ToInt16(value) < 5)
return Brushes.BlueViolet;
if (System.Convert.ToInt16(value) < 15)
return Brushes.CadetBlue;
else
return Brushes.Coral;
}
catch (Exception)
{
return Brushes.Black;
}
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
我綁定反射:
<ut:BindingReflector Target="{Binding Mode=OneWayToSource, Source = {StaticResource RetornaCorFundoGrid}, Path=CorFundoGridParameter}"
Source="{Binding Parameters, Mode=OneWay}" />
我行樣式:
<DataGrid.RowStyle>
<Style TargetType="{x:Type DataGridRow}">
<Setter Property="Background" Value="{Binding Path=Id, Converter={StaticResource RetornaCorFundoGrid}}"/>
</Style>
</DataGrid.RowStyle>
不,不,不,我可以改變我的背景顏色。我的問題是,當我這樣做,並選擇一行,而不是整行改變選擇的顏色,因爲我的網格不填滿列。由於還有更多2或3列的空間,我希望使這個選擇顏色完全填充行柵格,即使沒有更多列填充。 可以澄清我的問題嗎? –