我已经按照 example 构建了一个 UI ...并想添加两个按钮来重新排序“那里”列表中的列表框选定项目(上移 - 下移)。关于使用 Caliburn Micro 执行此操作的任何想法?
最佳答案
您需要为 SelectedThereItem
添加属性并将其绑定(bind)到 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"/>
View 模型:
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
}
关于wpf - Caliburn Micro Listbox 向上或向下移动项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28869749/