简体   繁体   中英

How to set TargetNullValue as folderpath in binding?

<TextBox Grid.Column="2"  Height="25"   IsReadOnly="True" TextAlignment="Right"  Text="{Binding ElementName=Mygroups, TargetNullValue= 'C:\myfolder1\mysubfolder1',Path=DataContext.FoldernameWithPath,UpdateSourceTrigger=PropertyChanged,Mode=TwoWay}"  />
<Button Grid.Column="3" Grid.Row="1"  Content="Browse"    Height="25" VerticalAlignment="Bottom"   MinWidth="47"   Command="{Binding ElementName=Mygroups,Path=DataContext.OpenFolderCommand}" CommandParameter="{Binding}" />

Before the user clicks the browse button,I need to bind the Textbox with default folderpath which is mentioned in TargetNullValue . But in my case it is binding like this C:myfolder1mysubfolder1

What I should do to bind the textbox like C:\\myfolder1\\mysubfolder1 ?

I don't know what is the reason but adding another '\\' seems to work:

<TextBox Grid.Column="2"  Height="25"   IsReadOnly="True" TextAlignment="Right"  Text="{Binding ElementName=Mygroups, TargetNullValue= 'C:\\myfolder1\\mysubfolder1',Path=DataContext.FoldernameWithPath,UpdateSourceTrigger=PropertyChanged,Mode=TwoWay}"  />
<Button Grid.Column="3" Grid.Row="1"  Content="Browse"    Height="25" VerticalAlignment="Bottom"   MinWidth="47"   Command="{Binding ElementName=Mygroups,Path=DataContext.OpenFolderCommand}" CommandParameter="{Binding}" />

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