开发者

wpf drag and drop setter invoke in source

I have a textbox like this:

<TextBox x:Name="txtCondition" Text="{Binding Path=Name ,Mode=TwoWay}"/>

When I select the text in this textbox and drag it to somewhere the setter of the binded property in this textbox is automa开发者_运维问答tically called, but I don't understand why :( .

Is it possible to turn it off somehow, that the wpf doesn't call the setter property in this case?

Thanks in advance for your help!

Regards, Zoli

EDIT:

We have to do some hack here :) .

We create a bool variable in the viewModel. Set the bool variable true in the previewDrop event, and when the setter is called check this bool variable value. If it's true, do nothing in the setter, and set the bool variable to false.

Other way, you can check the stacktrace to find out where this setter is invoked :)

But I'm very curious why wpf calls the setter of the binded property in the source when we drop an item from it, so If somebody know this reason please inform us :) .


The default binding behaviour of TextBoxes is to update when focus is lost, so when you drag away this is triggered. You could change the UpdateSourceTrigger of the binding to Explicit to avoid the automatic update but then of course you need to trigger the update manually at some time.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜