私は自分のコードでMVVM TreeViewを実装しました。 私は次のことを試してみました (私はツリービューを更新し続ける)フォーカスが私のツリーに最新のツリービューアイテムになることをしたい:MVVMツリービューでIsFocused
<TreeView ItemsSource="{Binding NotificationViewModel}" Name="MainTree">
<TreeView.ItemContainerStyle>
<!-- This Style binds a TreeViewItem to a NotificationViewModel. -->
<Style TargetType="{x:Type TreeViewItem}">
<Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}" />
<Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" />
<Setter Property="IsFocused" Value="{Binding IsFocused, Mode=TwoWay}" />
</Style>
</TreeView.ItemContainerStyle>
とのViewModelで:
// Constructor
public NotificationListViewModel(Notification notification)
{
_notification = notification;
_activityListViewModel = new ObservableCollection<ActivityListViewModel>();
_isSelected = true;
_isFocused = true;
}
private bool _isFocused;
public bool IsFocused
{
get { return _isFocused; }
set
{
if (value != _isFocused)
{
_isFocused = value;
this.OnPropertyChanged("IsFocused");
}
}
}
けど次のエラーが表示されます。
Error 1 The Property Setter 'IsFocused' cannot be set because it does not have an accessible set accessor. Line 115 Position 29. C:\My Visual Studio Projects\MainTreeView\View\NotificationListView.xaml 115 29
なぜIsSelectedやIsExpandedのようなフォーカスを実装できないのですか?