首页 新闻 会员 周边 捐助

帮忙看下这段xaml的问题谢谢

0
悬赏园豆:5 [已解决问题] 解决于 2013-10-14 10:59
 1  <WrapPanel Name="w1" Grid.Row="3" DataContext="{Binding RightRoom}">
 2             <StackPanel Orientation="Horizontal" Margin="5">
 3                 <TextBlock Text="房间号:"></TextBlock>
 4                 <TextBox x:Name="txt_houseID" Width="62" IsReadOnly="True" Text="{Binding RoomId,UpdateSourceTrigger=PropertyChanged}"></TextBox>
 5             </StackPanel>
 6             <StackPanel Orientation="Horizontal" Margin="5" >
 7                 <TextBlock Text="类型名称:"></TextBlock>
 8                 <ComboBox Name="cb_type" Width="57" DisplayMemberPath="TypeName" SelectedValuePath="TypeId"
 9         ItemsSource="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type Window}},Path=ComboText,Mode=OneWay}"></ComboBox>
10             </StackPanel>
11             <StackPanel Orientation="Horizontal" Margin="5">
12                 <TextBlock Text="价格:"></TextBlock>
13                 <TextBox x:Name="txt_Price" Width="50"    Text="{Binding Number,UpdateSourceTrigger=PropertyChanged}"></TextBox>
14             </StackPanel>
15             <StackPanel Orientation="Horizontal" Margin="5">
16                 <TextBlock Text="入住人数:"></TextBlock>
17                 <TextBox x:Name="txt_num" Width="67"  Text="{Binding GuestNumber,UpdateSourceTrigger=PropertyChanged}"></TextBox>
18             </StackPanel>
19             <StackPanel Orientation="Horizontal" Margin="5">
20                 <TextBlock Text="床位数:"></TextBlock>
21                 <TextBox x:Name="txt_bedNum" Width="65"  Text="{Binding BedNumber,UpdateSourceTrigger=PropertyChanged}"></TextBox>
22             </StackPanel>
23             <StackPanel Orientation="Horizontal" Margin="5">
24                 <TextBlock Text="状态:"></TextBlock>
25                 <ComboBox Name="cb_statue" Width="57" Text="{Binding State,UpdateSourceTrigger=PropertyChanged}">
26                     <ComboBoxItem Content="空闲"></ComboBoxItem>
27                     <ComboBoxItem Content="入住"></ComboBoxItem>
28                     <ComboBoxItem Content="维修"></ComboBoxItem>
29                 </ComboBox>
30             </StackPanel>
31             <StackPanel Orientation="Horizontal" Margin="5">
32                 <TextBlock Text="备注:"></TextBlock>
33                 <TextBox  x:Name="Description"  Width="637" TextWrapping="Wrap" Height="50" Text="{Binding Description,UpdateSourceTrigger=PropertyChanged}"></TextBox>
34             </StackPanel>
35         </WrapPanel>
View Code

问题出在combobox上,因为在WrapPanel中绑定了datacontent而我又要绑定combobox,所以将combobox的源地址指向Window可是还是找不到数据呢?

翻墙小龙虾的主页 翻墙小龙虾 | 初学一级 | 园豆:34
提问于:2013-10-12 09:23
< >
分享
最佳答案
0

试试

ItemsSource="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type Window}},Path=DataContext.ComboText,Mode=OneWay}">

收获园豆:5
刀是什么样的刀 | 小虾三级 |园豆:910 | 2013-10-12 13:02
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册