question

RodAtWork avatar image
0 Votes"
RodAtWork asked DaisyTian-1203 commented

Is there a problem with Watermark code?

@DaisyTian-MSFT I introduced the Watermark code you provided in answer to question I asked The SelectedValue property is never assigned. I don't know what I'm doing wrong. It has worked fine for me. However, one of my colleagues, when trying to implement the watermark, encountered this error:

That looks pretty good, but I get this exception when I add a new record.
"Specified Visual is already a child of another Visual or the root of a CompositionTarget." that's in WatermarkBehavior.cs in OnLoaded method.

I've looked up that error. It looks to me like it happens when some visual element gets introduced more than once into the visual tree. Could that be happening in the OnLoaded method of WatermarkBehavior?



windows-wpf
· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@RodAtWork
Could you show the related ComboBox Xaml code for me to reproduce the error? If it possible, please provide more detailed info of your visual element gets introduced more than once into the visual tree? By the way, my another watermark sample about Combobox may be helpful to you.


0 Votes 0 ·

Unfortunately, no @DaisyTian-MSFT, I cannot show you the code. My colleague, who complained about it, ripped the Watermark code out and replaced it with a button to the side of the ComboBox that's meant to be used when there's no SelectedItem selected.

0 Votes 0 ·

@RodAtWork
I can't reproduce your problem because there is no code. I'm sorry I wasn't able to help you with your problem.

1 Vote 1 ·

0 Answers