我已经在此example之后构建了一个用户界面...并希望添加两个按钮来重新排序列表框所选项目(向上移动 - 向下移动)在"那里&# 34;名单。有任何想法使用Caliburn Micro吗?
答案 0 :(得分:1)
您需要为SelectedThereItem
添加一个属性,并将其绑定到ThereList
:
XAML:
<ListBox x:Name="ThereList" SelectedItem="{Binding ThereSelectedItem}" ... />
<!-- Add buttons for ThereMoveUp and ThereMoveDown - use Caliburn naming convention -->
<Button x:Name="ThereMoveUp"/>
<Button x:Name="ThereMoveDown"/>
视图模型:
private Person _thereSelectedItem;
public Person ThereSelectedItem
{
get { return _thereSelectedItem; }
set
{
_thereSelectedItem = value;
NotifyOfPropertyChange(() => ThereSelectedItem);
NotifyOfPropertyChange(() => CanThereMoveDown);
NotifyOfPropertyChange(() => CanThereMoveUp);
}
}
// Add event method handlers for ThereMoveUp/Down
public bool CanThereMoveUp { get { return _thereSelectedItem != null; } }
public void ThereMoveUp
{
// Logic to move up
}
public bool CanThereMoveDown { get { return _thereSelectedItem != null; } }
public void ThereMoveDown
{
// Logic to move down
}