2012-10-25 59 views
0

我有兩個Datagrid Template列。 1)第一列是組合框 2)第二列與擴展IntergerUpDown控件WPF DataGrid元素其他DataGridTemplateColumn的名稱

我需要根據Combox框SelectedItem值設置IntegerUpDown最大值。

請幫助我如何做到這一點。下面的示例xaml。

<Grid><DataGrid ItemsSource="{Binding List1}" Name="x1"> 
      <DataGrid.Columns> 
       <DataGridTemplateColumn Header="ColorTemplate"> 
        <DataGridTemplateColumn.CellTemplate> 
         <DataTemplate> 
          <ComboBox ItemsSource="{Binding DataContext.List2, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type DataGrid}}}" 
             DisplayMemberPath="Name" SelectedValue="{Binding ColourId}" SelectedValuePath="Id" Tag="{Binding Id}" 
             HorizontalAlignment="Stretch" x:Name="discussTemplate" VerticalAlignment="Stretch" 
             /> 
         </DataTemplate> 
        </DataGridTemplateColumn.CellTemplate> 
       </DataGridTemplateColumn> 
       <DataGridTemplateColumn Header="UPDown" Width="Auto"> 
        <DataGridTemplateColumn.CellTemplate> 
         <DataTemplate> 
          <extToolkit:IntegerUpDown AllowSpin="True" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="Auto" Minimum="0" 
                x:Name="updown" 
                Maximum="{Binding ???}" > 

          </extToolkit:IntegerUpDown> 
         </DataTemplate> 
        </DataGridTemplateColumn.CellTemplate> 
       </DataGridTemplateColumn> 
      </DataGrid.Columns> 
     </DataGrid> 
    </Grid> 

回答

0

只是綁定到你的itemsrow的值?所以如果ColourID是由您的組合框設置的itemsrow的屬性。您可以將最大綁定到ColourID

<extToolkit:IntegerUpDown AllowSpin="True" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="Auto" Minimum="0" 
          Maximum="{Binding ColourId}" > 
</extToolkit:IntegerUpDown> 
+0

+1,也不要忘記執行'INotifyPropertyChanged'在您的項目類(在它宣佈'ColourId'屬性)。 –

+0

CombBox中的屬性「TAG」中存在一個值,該值必須設置爲最大的IntergerUpDown控件。 – Sanjaybxl

相關問題