8,737
社区成员
发帖
与我相关
我的任务
分享
public class StudentGroup : ViewModelBase
{
Student _stu;
public Student Stu
{
get { return _stu; }
set
{
_stu = value;
base.OnPropertyChanged("Stu");
}
}
}
public class Student : ViewModelBase
{
int _age;
string _name;
public int Age
{
get { return _age; }
set
{
_age = value;
base.OnPropertyChanged("Age");
}
}
public string Name
{
get { return _name; }
set
{
_name = value;
base.OnPropertyChanged("Name");
}
}
}
<DataTemplate x:Key="myParamTemplate">
<Border Name="border" BorderBrush="Aqua" BorderThickness="1"
Padding="5" Margin="5">
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0" Grid.Column="0" Text="Param:"/>
<TextBox Grid.Row="0" Grid.Column="1" Text="{Binding Path=Age,UpdateSourceTrigger=PropertyChanged}" />
<TextBlock Grid.Row="0" Grid.Column="2" Text="{Binding Path=Name,UpdateSourceTrigger=PropertyChanged}"/>
</Grid>
</Border>
</DataTemplate>
<ContentControl Content="{Binding Path=Stu,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
ContentTemplate="{StaticResource myParamTemplate}"
Background="Red"/>