tags:

views:

17

answers:

1

i want to change my button color when is pressed :

            <DataTemplate>
                <!--Click="btn_Click"-->
                <ItemsControl DataContext="{Binding}" ItemsSource="{Binding}">
                    <ItemsControl.ItemTemplate>
                        <DataTemplate>

                            <Button 
                                Name="btn"
                                DataContext="{Binding}"                             
                                Height="65" Width="79"
                                Background="Gray"
                                >

                                <Button.Template>

                                    <ControlTemplate TargetType="{x:Type Button}">
                                        <Ellipse Name="elipse1" Height="65" Width="79" Fill="{Binding Path=ButtonColor}" Visibility="Collapsed"></Ellipse>
                                        <ControlTemplate.Triggers>
                                             <Trigger Property="IsPressed" Value="True">
                                                <Setter TargetName="elipse1" Property="Visibility" Value="Visible"/>

                                            </Trigger>
                                         </ControlTemplate.Triggers>
                                    </ControlTemplate>
                                </Button.Template>

                            </Button>

                        </DataTemplate>
                    </ItemsControl.ItemTemplate>
                </ItemsControl>

it doesnt seem to work farther then that wjen i use the all triger <> the gray button is not showen has if this template is stronger then the binding ?is it true ? how to outcome it ?

A: 

The problem is that when the button isn't pressed - it has no visual impact (Visibility="Collapsed") - there are no elements inside the Button - thus it becomes invisible (and then it is hard to Press it :)).

You need to put something besides the Ellipse in the ControlTemplate to have it show something instead of the ellipse.

Goblin