datagrid와 좀 다르게 listbox를 바꿀수 있지만 datagrid가 더 나은듯하다...
app,xaml 이나 해당 xaml에 이걸 추가한다
<Style x:Key="listBoxItemStyle" TargetType="{x:Type ListBoxItem}">
<Style.Resources>
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}"
Color="Gray"/>
</Style.Resources>
</Style>
여기서 SystemColors.HighlightBrushKey 에 있는 color를 써야한다. 그렇게 하지 않고 rgb를 쓰면 투명도가 설정되어 있지않아
선택된 값이 보이지 않는다...
cs에서 하는 방법이 있긴하다 아래처럼
//색상을 생성
SolidColorBrush brush = new SolidColorBrush(Colors.Green);
//투명도를 20%로
brush.Opacity = 0.2;
brush.Opacity = 0.2;
//LIstBox Control의 Resource로 등록 SystemColors.HighlightBrushKey는 하이라이트 색상을 빨강으로 함....
_list.Resources.Add(SystemColors.HighlightBrushKey, brush);
_list.Resources.Add(SystemColors.HighlightTextBrushKey, new SolidColorBrush(Colors.Black));
_list.Resources.Add(SystemColors.HighlightBrushKey, brush);
_list.Resources.Add(SystemColors.HighlightTextBrushKey, new SolidColorBrush(Colors.Black));
하지만 xaml딴에서 해결하는게 나을듯하다.
listbox에 적용할때는
<ListBox IsSynchronizedWithCurrentItem="True" HorizontalAlignment="Stretch" Grid.ColumnSpan="1" Height="Auto" x:Name="listAlarmCameraList" DisplayMemberPath="strCameraName" Grid.Row="1" Style="{DynamicResource csListBox}" ItemContainerStyle="{StaticResource listBoxItemStyle}"/>
이부분을 추가하면된다.
ItemContainerStyle="{StaticResource listBoxItemStyle}"
text로 바꿀수 있는방법을 찾았다..ㅋㅋ
<ListBox> |
<ListBox.Resources> |
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="White"/> |
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" Color="Black"/> |
<SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="White"/> |
</ListBox.Resources> |
</ListBox> |
controlBrushkey는 disable이거나 focus가 다른쪽으로 갔을때 색이다.
'blend' 카테고리의 다른 글
xaml 주석 쉽게 다는법 (0) | 2009.03.12 |
---|---|
[Expression] DataGrid 컨트롤 스타일 입히기 1장 (0) | 2009.01.31 |
[blend] datagrid Selection Cell Color 바꾸기 (0) | 2009.01.29 |
datagrid header쪽에서 빈곳 색상바꾸기 (0) | 2009.01.09 |
datagrid header값 중간위치로 가게하기 (0) | 2009.01.07 |