<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}" />
在用户单击浏览按钮之前,我需要将文本框与 TargetNullValue 中提到的默认文件夹路径绑定。但就我而言,它像这样 C:myfolder1mysubfolder1
我该如何绑定文本框,例如 C:\ myfolder1 \ mysubfolder1 ?
答案 0 :(得分:1)
我不知道是什么原因,但是添加另一个'\'似乎可行:
<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}" />