Dave
Dave

Reputation: 241

WPF How to handle property names with spaces?

A simple question with i had problems several times and i dind´t find a solution so far. For sure it is a peanut for you.

I am trying to bind the Text property of a comboBox to a column in the dataTable. If the column name has no spaces it is working: For example:

Text="{Binding Path= MyColumn, ... }"

If the name has a space in between it doesn´t work: For example:

Text="{Binding Path= My Column, ... }"

There must be something indicating the compiler that the name consists of both words with the space ("My Column"). But i didn´t find it yet.

Thanks

Upvotes: 5

Views: 3006

Answers (2)

Jigar Tailor
Jigar Tailor

Reputation: 21

Text="{Binding Path= 'My Column', ... }"

didn't work for me so I tried the code below that worked fine.

<TextBox>
    <TextBox.Text>
        <Binding Path="My Column"/>
    </TextBox.Text>  
</TextBox>

Upvotes: 1

Dave
Dave

Reputation: 241

The following delimiters did not work: "" [] {}

What you need is single quotes ''

Text="{Binding Path= 'My Column', ... }"

Upvotes: 10

Related Questions