开发者

WPF - Generate BitmapSource from Over state of a button

开发者 https://www.devze.com 2022-12-16 03:01 出处:网络
I can generate a BitmapSource from a button fine, however it always is just the image of the normal state of the button.

I can generate a BitmapSource from a button fine, however it always is just the image of the normal state of the button.

I want to be able to generate a BitmapSource of the over state of a button.

I tried calling VisualStateManager.GoToState((FrameworkElement)target, "MouseOver", true); before calling my code to generate the BitmapSource. It correctly changes the button 开发者_开发百科to the overstate on the GUI, but the BitmapSource is still that of the button in the normal state.


I figured out the problem. VisualStateManager.GoToState((FrameworkElement)target, "MouseOver", true); just begins the transition to the specified state. I needed to give control back to the UI thread and wait for the state to actually change before trying to save the bitmap.

0

精彩评论

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

关注公众号