1
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:LayoutCreator"
mc:Ignorable="d"
x:Class="LayoutCreator.Cell"
x:Name="UserControl" Width="100" Height="100">
<Grid x:Name="LayoutRoot">
<Border Background="#FFF2F0F0" x:Name="CellBorder" BorderThickness="4,4,4,4">
<Rectangle Stroke="#FF000000" Width="Auto" Height="Auto" x:Name="ActualCell" Style="{DynamicResource RectangleStyle}" MouseLeftButtonDown="ActualCell_MouseLeftButtonDown" />
</Border>
</Grid>
<UserControl.Resources>
<Style TargetType="{x:Type local:Cell}">
<Style.Triggers>
<Trigger Property="IsSelected" Value="true">
<!--here i want to update the properties of Border and Rectangle-->
</Trigger>
</Style.Triggers>
</Style>
</UserControl.Resources>
</UserControl>
public partial class Cell
{
public bool IsSelected
{
get { return (bool)GetValue(IsSelectedProperty); }
set { SetValue(IsSelectedProperty, value); }
}
public static DependencyProperty IsSelectedProperty =
DependencyProperty.Register("IsSelected", typeof(bool), typeof(Cell),
new FrameworkPropertyMetadata(false));
public bool IsBlocked
{
get { return (bool)GetValue(IsBlockedProperty); }
set { SetValue(IsBlockedProperty, value); }
}
public static DependencyProperty IsBlockedProperty =
DependencyProperty.Register("IsBlocked", typeof(bool), typeof(Cell),
new FrameworkPropertyMetadata(false));
public Cell()
{
this.InitializeComponent();
}
private int _RowPositon;
public int RowPositon
{
get { return _RowPositon; }
set { _RowPositon = value; }
}
private int _ColPosition;
public int ColPosition
{
get { return _ColPosition; }
set { _ColPosition = value; }
}
private void ActualCell_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
this.IsSelected = !this.IsSelected;
}
}
那是什麼:)? – Anvaka 2009-09-23 15:59:52