wpf2017. 9. 12. 12:40

listview
1
2
3
4
5
6
7
8
9
10
11
12
                <ListView.ItemContainerStyle>
                    <Style TargetType="{x:Type ListViewItem}">
                        <Setter Property="Background" Value="Transparent" />
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="{x:Type ListViewItem}">
                                    <ContentPresenter />
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </ListView.ItemContainerStyle>


button


1
2
3
4
5
6
7
8
9
10
11
12
13
14
 <Button.Style>
                <Style TargetType="{x:Type Button}">
                    <Setter Property="Background" Value="Transparent"/>
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="{x:Type Button}">
                                <Border Background="{TemplateBinding Background}">
                                    <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
                                </Border>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
</Button.Style>


Posted by 동동(이재동)
Surface2012. 4. 25. 14:41

반대로 Media.Color를 Brush로 바꾸는건 쉬웠지만

 

Brush를 Color로 바꾸는건 힘들었다.

 

var temp = ((e.Source as ListBox).SelectedItem as Brush);
         SolidColorBrush c = new BrushConverter().ConvertFromString(temp.ToString()) as SolidColorBrush;

         SurfaceInkCanvasContainer.DefaultDrawingAttributes.Color = c.Color;

내가 사용한 방법이다. brush를 SolidColorBrush로 BrushConvert의 도움을 받아서 컨버팅한후 Color프로퍼티를 이용하였다.

참고 : http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/fb164db0-c169-4d0e-85dc-c79163ea3aac/

Posted by 동동(이재동)