简体   繁体   中英

Setter Property in XAML

what is wrong?

<Style TargetType="ComboBox" x:Key="ComboBoxStyleMex">
    <Setter Property="Name" Value="stcombo" />
</Style>

and

<DataGridComboBoxColumn SelectedItemBinding ="{Binding name_ru}" Header="Статус" CellStyle="{StaticResource ComboBoxStyleMex}">
</DataGridComboBoxColumn>

why name is not set?

Please try to do the Binding for SelectedValueBinding instead of SelectedItemBinding and try again

Hope this helps..

Name can not be set in a Style.

A Name set from a Style applied to multiple instances in the same scope, like a Window, should in theory result in compiler errors due to duplicate names (remember Name turns into a code-behind accessible variable name) but Styles are not applied until runtime so the compiler wouldn't know about the Name from the Style, which it would need to use during compilation. To prevent this paradox, Styles can't set Name.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM