FunctionZero
  • Libraries
    • Maui.MvvmZero
      • Overview
      • Quickstart
      • Walkthrough
        • Create your application
        • Create your ContentPages
        • Create your ViewModels
        • Register your new content
        • Launching our app!
        • Adding Navigation
        • Summary
      • Recommended naming conventions
      • Configuring your root Page
        • Root ContentPage
        • Root NavigationPage
        • Root TabbedPage
        • Root FlyoutPage
      • A note on Singleton vs Transient
      • Recommended base classes for PageViewModels and ViewModels
    • Maui.Controls
      • ExpanderZero
      • FocusScrollZero
      • LabelZero
      • ListViewZero
      • MaskZero
      • MultiViewZero
      • TreeViewZero
    • CommandZero
    • Maui.BindZero
      • Quickstart
      • z:Bind
      • Examples
      • The Great Escape
      • Casting
      • Short Circuit
      • Errors
      • Aliases
      • Value types and Reference types
      • z:Function
      • z:TapTrigger
      • z:EdgeTrigger
      • z:Latch
      • Advanced Usage - Functions, aliases and operator-overloads
    • AnimationZero
    • LocalisationZero
Powered by GitBook
On this page
  1. Libraries
  2. Maui.BindZero

The Great Escape

... and other cautionary tales

As with xaml, string literals can be enclosed within 'single quotes' or "double quotes" with appropriate use of xml escape-sequences.

Commas

If your expression string has commas in it, you must hide them from the xaml parser, otherwise z:Bind etc. will be given an incomplete string and things won't work as expected.

You can do this by enclosing the string inside quotes, like this:

Something="{z:Bind 'SomeFunction(param1, param2)'}"

or this

Something="{z:Bind \"SomeFunction(param1, param2)\"}"

and so on

Strings

If your expression string has string literals in it, you must 'escape' them, otherwise z:Bind etc. will be given an incorrect string and things won't work as expected. For example:

"{z:Bind Status == \'Administrator\'}"

or this

"{z:Bind Status == '\'Administrator\''}"

and so on

Long form

If your expression is getting bogged down in escape-sequences and commas and quotes, or if that's just the way you roll, you can use the long-form of expressing a z:Bind expression:

<Label Text="{z:Bind '\'Score: \'+ Count + \' points\''}"

becomes

<Label>
    <Label.Text>
        <z:Bind>
            'Score: '+ Count + ' points'
        </z:Bind>
    </Label.Text>
</Label>
PreviousExamplesNextCasting

Last updated 1 year ago