开发者

Attached properties Clearing local value but xaml not refreshing

开发者 https://www.devze.com 2023-04-06 11:32 出处:网络
I derived the StackPanel class in a OrderableStack Class. My aim is to allow a Stack\'s child to set an attached property Named \'First\' to true and so this child becomes the first element in the s

I derived the StackPanel class in a OrderableStack Class.

My aim is to allow a Stack's child to set an attached property Named 'First' to true and so this child becomes the first element in the stack.

When the attached property is set to true, the PropertyChangedCallback procedure defined in Metadata is called and it first removes the child element from the stack , then inserts it at position 0. Finally all the other children have their 'First' attached property set to False.

It works , but :

-if the attached property is already defined in xaml when i display it in VS 2010, VS 2010 is indicating that 'a reference is not set...'

-i can check that every other child, except the one defined as 'first' , has its OrderableStack.First set to false in the Properties Window, but the xaml is not updated. So many children can have the Orde开发者_C百科rableStack.First attached property set to true (in XAML), even if actually only the last child to be set has the True value.

Could you help me?


if the attached property is already defined in xaml when i display it in VS 2010, VS 2010 is indicating that 'a reference is not set...'

Does this stop you from building and running your app? The way you can avoid this "designer" error is to put some nullability checks around your attached property's PropertyChangedCallback code.

i can check that every other child, except the one defined as 'first' , has its OrderableStack.First set to false in the Properties Window, but the xaml is not updated.

I didnt get that last bit. Do you expect your XAML designer to "simulate" the ordering in design mode? Then the best candidate designer is XAML Pad or Expression Blend. Visual Studio designers are sadly not the best out there. They also do not "simulate" animations / triggers.

I hope this helps.

0

精彩评论

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

关注公众号