![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
| |
| | #1 (permalink) |
| | FocusVisualStyle I was expecting this xaml to change the style of the button with the focus <Grid> <Grid.Resources> <Style x:Key="focusedButton" TargetType="{x:Type Button}"> <Setter Property="Background" Value="Yellow" /> </Style> </Grid.Resources> <Grid.RowDefinitions> <RowDefinition Height="Auto"></RowDefinition> <RowDefinition Height="Auto"></RowDefinition> </Grid.RowDefinitions> <Button Grid.Row="0" FocusVisualStyle="{StaticResource focusedButton}" Content="Test1" /> <Button Grid.Row="1" FocusVisualStyle="{StaticResource focusedButton}" Content="Test2" /> </Grid> But it has no effect. Could someone enlighten me. Is it that the FocusVisualStyle require content not just setters on properties? Thanks |
My System Specs![]() |
| | #2 (permalink) |
| | RE: FocusVisualStyle You should create a focusvisualstyle instead of restyling the button. Try this: <StackPanel xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" > <Grid> <Grid.Resources> <Style x:Key="focusedButton"> <Setter Property="Control.Template"> <Setter.Value> <ControlTemplate> <Rectangle StrokeThickness="2" Stroke="Red"/> </ControlTemplate> </Setter.Value> </Setter> </Style> </Grid.Resources> <Grid.RowDefinitions> <RowDefinition Height="Auto"></RowDefinition> <RowDefinition Height="Auto"></RowDefinition> </Grid.RowDefinitions> <Button Grid.Row="0" FocusVisualStyle="{StaticResource focusedButton}" Content="Test1" /> <Button Grid.Row="1" FocusVisualStyle="{StaticResource focusedButton}" Content="Test2" /> </Grid> </StackPanel> "joe_bloggs" wrote: > I was expecting this xaml to change the style of the button with the focus > > <Grid> > <Grid.Resources> > <Style x:Key="focusedButton" TargetType="{x:Type Button}"> > <Setter Property="Background" Value="Yellow" /> > </Style> > </Grid.Resources> > <Grid.RowDefinitions> > <RowDefinition Height="Auto"></RowDefinition> > <RowDefinition Height="Auto"></RowDefinition> > </Grid.RowDefinitions> > > <Button Grid.Row="0" FocusVisualStyle="{StaticResource focusedButton}" > Content="Test1" /> > <Button Grid.Row="1" FocusVisualStyle="{StaticResource focusedButton}" > Content="Test2" /> > </Grid> > > But it has no effect. > Could someone enlighten me. > Is it that the FocusVisualStyle require content not just setters on > properties? > > Thanks |
My System Specs![]() |
| | #3 (permalink) |
| | RE: FocusVisualStyle Basically, the idea of FocusVisualStyle is to add an AdornerLayer on top of the control. So the ContentTemplate of FocusVisualStyle won't merge with the control's template. Bai Shi "joe_bloggs" wrote: > Thanks for the reply. > > How is the ContentTemplate applied to the control that it is applied to? > > The ContentTemplate does not replace the content of the control it is > applied to, so how is it combined? > > Thanks > > > > > "Bai Shi" wrote: > > > You should create a focusvisualstyle instead of restyling the button. > > Try this: > > <StackPanel > > xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" > > xmlns:sys="clr-namespace:System;assembly=mscorlib" > > xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" > > > <Grid> > > <Grid.Resources> > > <Style x:Key="focusedButton"> > > <Setter Property="Control.Template"> > > <Setter.Value> > > <ControlTemplate> > > <Rectangle StrokeThickness="2" Stroke="Red"/> > > </ControlTemplate> > > </Setter.Value> > > </Setter> > > </Style> > > </Grid.Resources> > > <Grid.RowDefinitions> > > <RowDefinition Height="Auto"></RowDefinition> > > <RowDefinition Height="Auto"></RowDefinition> > > </Grid.RowDefinitions> > > > > <Button Grid.Row="0" FocusVisualStyle="{StaticResource focusedButton}" > > Content="Test1" /> > > <Button Grid.Row="1" FocusVisualStyle="{StaticResource focusedButton}" > > Content="Test2" /> > > </Grid> > > > > </StackPanel> > > > > > > "joe_bloggs" wrote: > > > > > I was expecting this xaml to change the style of the button with the focus > > > > > > <Grid> > > > <Grid.Resources> > > > <Style x:Key="focusedButton" TargetType="{x:Type Button}"> > > > <Setter Property="Background" Value="Yellow" /> > > > </Style> > > > </Grid.Resources> > > > <Grid.RowDefinitions> > > > <RowDefinition Height="Auto"></RowDefinition> > > > <RowDefinition Height="Auto"></RowDefinition> > > > </Grid.RowDefinitions> > > > > > > <Button Grid.Row="0" FocusVisualStyle="{StaticResource focusedButton}" > > > Content="Test1" /> > > > <Button Grid.Row="1" FocusVisualStyle="{StaticResource focusedButton}" > > > Content="Test2" /> > > > </Grid> > > > > > > But it has no effect. > > > Could someone enlighten me. > > > Is it that the FocusVisualStyle require content not just setters on > > > properties? > > > > > > Thanks |
My System Specs![]() |
| Thread Tools | |
| |