Bonjour
une petite question un peu tordu sur wpf
j'ai un style de bouton standard disons Toto
j'aimerais avoir des sur style Toto.OK qui définissent un content par défaut
donc je fais la chose suivante
sauf que comme si je colle un deuxième bouton avec le même style je perds les informations (content) du premier
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51 <Window.Resources> <Style x:Key="Toto" TargetType="{x:Type Button}"> <Setter Property="BorderBrush" Value="DarkGray" /> <Setter Property="BorderThickness" Value="1" /> <Setter Property="MinWidth" Value="150" /> <Setter Property="MinHeight" Value="32" /> <Setter Property="Width" Value="150" /> <Setter Property="Height" Value="32" /> </Style> <Style x:Key="Toto.Ok" TargetType="{x:Type Button}" BasedOn="{StaticResource Toto}"> <Setter Property="Content"> <Setter.Value> <StackPanel Orientation="Horizontal"> <TextBlock Text="Ok" Margin="4 0 0 0" VerticalAlignment="center" /> </StackPanel> </Setter.Value> </Setter> </Style> </Window.Resources> <Grid> <Button Content="Button" Style="{StaticResource Toto}" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Height="50" Width="230" /> <Button Style="{StaticResource Toto.Ok}" HorizontalAlignment="Left" Margin="10,89,0,0" VerticalAlignment="Top" Height="50" Width="230" /> <Button Style="{StaticResource Toto.Ok}" HorizontalAlignment="Center" Margin="0,89,0,0" VerticalAlignment="Top" Height="50" Width="230" /> </Grid>
ca donne le sentiment que le content est le même pour tout le monde
je comprends pas trop comment résoudre ce problème
si vous avez une idee ....
Partager