Caliburn micro(1.3)/ MVVMとSilverlightを使用しています。 itemsource RadGridViewを更新すると、選択したアイテムが失われます。 MVVMを実装するときに、選択した項目を保存する動作を実装する方法についてのブログを見つけました。選択したアイテムを取得することはできますが、アイテムソースを一度リフレッシュすると戻すことはできません。 someoneshow私はどのようにcaliburn.microとRadGridVIewを使用して実装することができますか?私は、キャリバンマイクロコンベンションを作成するのが最善の方法だと思っていますが、selectedItemではなくselectedItemのコンベンションを作成するためのリファレンスしか見つけることができません。caliburn.micro/Telerik RadGridView/Silverlightの使用時に選択した項目を保存します
これを達成する方法を教えてもらえますか?私は以下を試しましたが、うまくいきません。
private static void SetRadGridSelecteditemsConventions()
{
ConventionManager
.AddElementConvention<DataControl>(DataControl.ItemsSourceProperty, "SelectedItem", "SelectionChanged")
.ApplyBinding = (viewModelType, path, property, element, convention) =>
{
ConventionManager.SetBinding(viewModelType, path, property, element, convention, DataControl.ItemsSourceProperty);
if (ConventionManager.HasBinding(element, DataControl.SelectedItemProperty))
return true;
var index = path.LastIndexOf('.');
index = index == -1 ? 0 : index + 1;
var baseName = path.Substring(index);
foreach (var selectionPath in
from potentialName in ConventionManager.DerivePotentialSelectionNames(baseName)
where viewModelType.GetProperty(potentialName, BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance) != null
select path.Replace(baseName, potentialName))
{
var binding = new Binding(selectionPath) { Mode = BindingMode.TwoWay };
BindingOperations.SetBinding(element, DataControl.SelectedItemProperty, binding);
}
return true;
};
}
おかげで、 ステファン