Two examples of WPF using MultiBinding in XAML

Source: Internet
Author: User

the principle of using multibinding: There is more than one data source ;

1. Requirements: In a need to display the content, the different parts to be processed differently, you can use multibinding

1 <TextBlock>2           <Textblock.text>3                      <multibindingStringFormat="{}{0} {1} {2}">4                                 <BindingPath= "Downloadviewmodel.totaldevicecount" />5                                  <BindingPath= "Language"Converter="{StaticResource Lanconverter}"Converterparameter= "Problem"/>6                                   <BindingPath= "Downloadviewmodel.totaldevicecount"Converter="{StaticResource Numtopluralconverter}"Converterparameter= "Driver" />7                        </multibinding>8              </Textblock.text>9  </TextBlock>
View Code

Use MultiBinding's StringFormat directly to handle

2. Requirements: Data sources are different, but need to use these data sources for judgment or processing

1 <Button.commandparameter>2          <multibindingConverter="{StaticResource Windowmulitconverter}">3                  <BindingRelativeSource="{RelativeSource Ancestortype=window,ancestorlevel=1}"/>4                  <Binding/>5          </multibinding>6 </Button.commandparameter>
View Code

Two examples of WPF using MultiBinding in XAML

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.