WPF error: the "Property" must have a non-null value ., Wpfproperty

Source: Internet
Author: User

WPF error: the "Property" must have a non-null value ., Wpfproperty
This problem usually occurs when the type specified by Property in Triggers is Nullable.
The solution is to replace Trigger with DataTrigger and convert it to a non-Null value using Binding + Converter.
For example: <Style x: Key = "DisableStyle" TargetType = "Button">
<Style. Triggers>
<MultiDataTrigger>
<MultiDataTrigger. Conditions>
<Condition Binding = "{Binding ElementName = ckb1, Path = IsChecked, Converter = {StaticResource NullableToBooleanConverter}" Value = "true"> </Condition>
<Condition Binding = "{Binding ElementName = ckb2, Path = IsChecked, Converter = {StaticResource NullableToBooleanConverter}" Value = "true"> </Condition>
</MultiDataTrigger. Conditions>
<Setter Property = "IsEnabled" Value = "False"> </Setter>
</MultiDataTrigger>
</Style. Triggers>
</Style>


NullableToBooleanConverter: public object Convert (object value, Type targetType, object parameter, CultureInfo culture) {Nullable <bool> isCheck = value as Nullable <bool>; if (null = isCheck) {return false;} else {return isCheck. value ;}}
Hibernate cascade storage error: not-null property references a null or transient value:

If not-null = false, no error is returned. A null value is inserted.

What are the values of the Property of wpf setter Property?

Er... This depends on the object. For example:
<Button>
<Button. Style>
<Style TargetType = "Button">
<Setter Property = "Content" Value = "I Am a button! "/>
</Style>
</Button. Style>
</Button>

The above code is used to set the Button style,
The Setter Property is used to set the Content attribute for the Button,
It can be seen that the Property names allowed by Setter Property are specified by TargetType.
You don't need to worry about the attribute values. WPF will automatically convert the values.

If TargetType = "TextBlock ",
<Setter Property = "Content" Value = "I Am a button! "/>
An error is reported because TextBlock does not have the Content attribute. It should be set:
<Setter Property = "Text" Value = "I Am a Text display area! "/>

You can use the following extended attributes:
<Setter Property = "Canvas. Left" Value = "50"/>
<Setter Property = "Panel. ZIndex" Value = "10000"/>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.