Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class CarInfo : DependencyObject
- {
- public static readonly DependencyProperty MaxSpeedProperty =
- DependencyProperty.Register("MaxSpeed", typeof (double), typeof (CarInfo), new PropertyMetadata(0.0));
- public double MaxSpeed
- {
- get { return (double) GetValue(MaxSpeedProperty); }
- set { SetValue(MaxSpeedProperty, value); }
- }
- }
- public class Car : DependencyObject
- {
- public static readonly DependencyProperty InfoProperty =
- DependencyProperty.Register("Info", typeof (CarInfo), typeof (Car), new PropertyMetadata(null));
- public CarInfo Info
- {
- get { return (CarInfo) GetValue(InfoProperty); }
- set { SetValue(InfoProperty, value); }
- }
- }
- <Style TargetType="assembly:Car">
- <Setter Property="Template">
- <Setter.Value>
- <ControlTemplate TargetType="assembly:Car">
- <Grid >
- !--> <TextBlock Text="{Binding Path=MaxSpeed}" />
- </Grid>
- </ControlTemplate>
- </Setter.Value>
- </Setter>
- </Style>
- <TextBlock Text="{Binding Path=Info.MaxSpeed}" />
- <TextBlock Text="{Binding Path=Info.MaxSpeed, RelativeSource={RelativeSource TemplatedParent}}" />
- <TextBlock Text="{Binding Path=Info.MaxSpeed}" />
- <TextBlock Text="{Binding Path=Info.MaxSpeed, RelativeSource={RelativeSource Mode=TemplatedParent}}" />
- Car.Info = new CarInfo { MaxSpeed = 100.0 };
Add Comment
Please, Sign In to add comment