Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF How to handle property names with spaces?

Tags:

c#

properties

wpf

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

like image 395
Dave Avatar asked Jul 31 '15 15:07

Dave


2 Answers

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

What you need is single quotes ''

Text="{Binding Path= 'My Column', ... }"
like image 112
Dave Avatar answered Oct 04 '22 20:10

Dave


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>
like image 42
Jigar Tailor Avatar answered Oct 04 '22 21:10

Jigar Tailor