2014-06-23 2 views
0

EDIT : 실제로 문제를 해결할 수있었습니다. 이전에 설정된 Binding Color 대신 Binding Value.Color을 사용하고있었습니다. 어쨌든 도움을 주셔서 감사합니다! XAML에서의 ColorPicker :wpf xctk : ColorPicker 기본 색상을 설정하는 방법

나는 A A xctk을 가지고 GUI를 만들고있어

<GridViewColumn.CellTemplate> 
    <DataTemplate> 
     <xctk:ColorPicker SelectedColor="{Binding Value.Color}" Width="40"/> 
    </DataTemplate> 
</GridViewColumn.CellTemplate> 

현재 선택기의 기본 색상은 블루, 나는 검은 색으로 변경하고 싶습니다. 어떻게해야합니까? 당신의 재산은 다음 파란색 반환 Value.Color 경우

답변

0

색상 선택기는 검은 색으로 재산 색상을 변경하여

그래서 파란색으로 표시됩니다이 경우

그래서 당신의 바인더 제본 속성 값에서 기본 색상을 보여줍니다 것 로 변경 블랙

하지만

을 변경 할 때 당신은 검은 색의 기본 값으로 자리 표시 자 속성의 사용을 만들 수있는 속성 값을 변경하고 소스를 업데이트하지 않는 경우 경우 다음, 위의 예에서 자리 표시 방법

<Grid Background="{Binding Value}"> 
    <xctk:ColorPicker SelectedColor="{Binding PlaceHolder}" Width="40" VerticalAlignment="Center"/> 
</Grid> 

보기 모델

bool isDefault = true; 
public Color PlaceHolder 
{ 
    get 
    { 
     if (isDefault) 
      return Colors.Black; 

     return Value.Color; 
    } 
    set 
    { 
     Value.Color = value; 
     isDefault = false; 
    } 
} 

public SolidColorBrush Value { get; set; } 

예를 들어 내가 형 SolidColorBrush의 값을 가정하고 .NET 4를 사용하는 경우 나는 Value = new SolidColorBrush(Colors.Green);

0

로 초기화 Resource 몇 가지를 정의하여 GridView에서 선택한 행의 Background 색을 변경할 수 있습니다. GridView.Resources 컬렉션에 다음을 추가하면됩니다.

<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Blue" /> 
<SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="Blue" /> 
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" Color="Black" /> 
<SolidColorBrush x:Key="{x:Static SystemColors.ControlTextBrushKey}" Color="Black" />