Reputation: 11
this is my code:
public Foo()
{
InitializeComponent();
this.WhenActivated(d =>
{
ViewModel ??= Locator.Current.GetService<FooViewModel>();
this.BindInteraction(ViewModel, vm => vm.SetClipboardTextInteration, SetClipboardSelectedTextInteraction)
.DisposeWith(d);
//подписка на нажатие + ctrl+c
var pointerPressedObservable = Observable.FromEventPattern<EventHandler<PointerPressedEventArgs>, PointerPressedEventArgs>(
h => this.PointerPressed += h,
h => this.PointerPressed -= h)
.Subscribe(h =>
{
if (h.Sender != this && h.Sender is Foo)
{
Console.WriteLine("a");
this._isSelected = false;
}
else
{
Console.WriteLine("a");
this._isSelected = true;
}
})
.DisposeWith(d);
var keyCtrlCPressObservable = Observable.FromEventPattern<EventHandler<KeyEventArgs>, KeyEventArgs>(
h => this.KeyDown += h,
h => this.KeyDown -= h)
.Subscribe(h =>
{
if(h.EventArgs.Key == Key.C && h.EventArgs.KeyModifiers == KeyModifiers.Control && this._isSelected)
{
Console.WriteLine("test");
}
})
.DisposeWith(d);
});
}
my Foo is ReactiveUserControl. It is a button which darkens when it is selected. I need to use its selection - when it is darkened and when i hit Ctrl+C it gets copied. The problem is that my debugger(Console.WriteLine blocks) doesn't do anything. It doesn't stop on these blocks so they got stepped over. Why?
I think I need to bind them someway but I don't know how
Upvotes: 0
Views: 88