none
wpf mouseover fill rectangle

    Question

  • Hi,

    I have Grid in wpf. When I do mouseover on rectangle, I can see color change. But when I do mouseover on content, I see original color of rectangle.

    What should I write to apply same mouseover effect on ContentPresenter or is there any way to change rectangle background color on mouse over of content presenter.     


        
        <Grid Background="{TemplateBinding Background}" x:Name="dgColumnHeader">
                 <Border x:Name="border" BorderBrush="Black" BorderThickness="0,0,1,1" Grid.ColumnSpan="1">
                        <Rectangle Width="116" Margin="3,3,3,3" HorizontalAlignment="Center" RadiusX="7" RadiusY="7">
                            <Rectangle.Style>
                                <Style TargetType="{x:Type Rectangle}">
                                    <Setter Property="Fill" Value="{DynamicResource ContentOutofFocusBrush}"></Setter>
                                    <Style.Triggers>
                                        <Trigger Property="IsMouseOver" Value="True">
                                            <Setter Property="Fill" Value="{DynamicResource ActiveItemBrush}" />
                                        </Trigger>
                                    </Style.Triggers>
                                </Style>
                            </Rectangle.Style>
                        </Rectangle>
                    </Border>
                    <ContentPresenter x:Name="content"  HorizontalAlignment="Center"  VerticalAlignment="Center" Content="{TemplateBinding Content}" />
                </Grid>

    Thanks
    Dee
    Tuesday, May 01, 2012 2:34 AM

All replies

  • Hi,

    The content presenter is of a container, the background colour is up to the panel where the content presented. And the content might already have panel having similar visual effect.

    Regards,

    Tuesday, May 01, 2012 4:11 AM