I have a WPF application in which I have a resource dictionary. In the dictionary, I have a new style for Button that looks like this:
<Style x:Key="MenuButtonStyle" TargetType="Button"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type Button}"> <Grid> <Image x:Name="Imager" RenderOptions.BitmapScalingMode="HighQuality" Width="{TemplateBinding Width}" Height="{TemplateBinding Height}" Source="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Tag}" VerticalAlignment="Center" HorizontalAlignment="Center" Stretch="UniformToFill"/> </Grid> <ControlTemplate.Triggers> <Trigger Property="IsMouseOver" Value="true"> <Setter TargetName="Imager" Property="Width" Value="24" /> <Setter TargetName="Imager" Property="Height" Value="24" /> </Trigger> <Trigger Property="IsPressed" Value="true"> <Setter TargetName="Imager" Property="Width" Value="16" /> <Setter TargetName="Imager" Property="Height" Value="16" /> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </Style>
And use this stye in my XAML, like this:
<Button x:Name="Home" Style="{DynamicResource MenuButtonStyle}" Width="20" Height="20" Tag="\Images\Home.png"/> <Button x:Name="Settings" Style="{DynamicResource MenuButtonStyle}" Width="20" Height="20" Tag="\Images\Settings.png"/>
Now, what I want to do is create a new Button -style property called OverWidth and OverHeight to use it like this:
<Trigger Property="IsMouseOver" Value="true"> <Setter TargetName="Imager" Property="Width" Value= OVERWIDTH/> <Setter TargetName="Imager" Property="Height" Value= OVERHEIGHT/> </Trigger>
And in XAML:
<Button x:Name="Home" Style="{DynamicResource MenuButtonStyle}" Width="20" Height="20" Tag="\Images\Home.png" OVERWIDTH = "24"/>
I donβt even know if this is possible. I do not want to use Binding SomeIntenger from C # code. Thanks in advance.
c # properties wpf xaml custom-controls
oimitro
source share