DataGrid
オブジェクトを含む WPF アプリケーションにコントロールがあります。ユーザーの操作によって変更できる、そのオブジェクトのブール値のプロパティがあります。そのプロパティの値が変更されたときに行のスタイルを変更する必要があります。
から派生するクラスを作成しましたStyleSelector
:
public class LiveModeSelector : StyleSelector {
public Style LiveModeStyle { get; set; }
public Style NormalStyle { get; set; }
public override Style SelectStyle( object item, DependencyObject container ) {
DataGridRow gridRow = container as DataGridRow;
LPRCamera camera = item as LPRCamera;
if ( camera != null && camera.IsInLiveMode ) {
return LiveModeStyle;
}
return NormalStyle;
}
}
問題の View Model クラスは を実装しINotifyPropertyChanged
、PropertyChanged
問題のプロパティが変更されたときにイベントを発生させます。
// Note: The ModuleMonitor class implements INotifyPropertyChanged and raises the PropertyChanged
// event in the SetAndNotify generic method.
public class LPRCamera : ModuleMonitor, ICloneable {
. . .
public bool IsInLiveMode {
get { return iIsInLiveMode; }
private set { SetAndNotify( "IsInLiveMode", ref iIsInLiveMode, value ); }
}
private bool iIsInLiveMode;
. . .
/// </summary>
public void StartLiveMode() {
IsInLiveMode = true;
. . .
}
public void StopLiveMode() {
IsInLiveMode = false;
. . .
}
}
ユーザーが必要なアクションを実行すると、プロパティの値が変更されますが、スタイルは変更されません。
SelectStyle メソッドにブレークポイントを配置しましたが、コントロールが最初に読み込まれたときにブレークポイントがヒットすることがわかりますが、プロパティの値が変更されたときにはヒットしません。
私は何が欠けていますか?