Home > Net >  WPF MVVM DataGrid content DataGridComboBoxColumn bound data source drop-down box?
WPF MVVM DataGrid content DataGridComboBoxColumn bound data source drop-down box?

Time:05-04

 & lt; The DataGrid IsReadOnly="False" AutoGenerateColumns="False" Background="white" 
CanUserResizeColumns="False" CanUserResizeRows="False" SelectionMode="Single"
CanUserReorderColumns="False" AlternationCount="2" RowHeaderWidth="0" CanUserAddRows="False" ItemsSource="{Binding StaffVos, Mode=TwoWay}" SelectedItem="{Binding SelectStaffEntity}" & gt;

TextBinding="{Binding QualityGauge}" SelectedValueBinding="{Binding QualityGauge}"/& gt;







This is the DataGrid xaml I need to put quality as the column drop-down box bound data source;
 & lt; DataGridComboBoxColumn Header="quality" Width="*" ItemsSource="{Binding QualityGauge}" DisplayMemberPath="{Binding QualityGaugeName}" SelectedValuePath="{Binding QualityGaugeID}" 
TextBinding="{Binding QualityGauge}" SelectedValueBinding="{Binding QualityGauge}"/& gt;

Unit where I use the drop-down ComboBox binding items, but I have tried two ways, not bound up,

///& lt; Summary> 
///
///& lt;/summary>
Private ListPublic List{
The get {return _UnitSheet; }
Set
{
If (_UnitSheet!=value)
{
_UnitSheet=value;
RaisePropertyChanged (()=& gt; UnitSheet);
}
}
}

///& lt; Summary>
///quality
///& lt;/summary>
Private ListPublic List{
The get {return _QualityGauge; }
Set
{
If (_QualityGauge!=value)
{
_QualityGauge=value;
RaisePropertyChanged (()=& gt; QualityGauge);
}
}
}

Here is the association and drop-down box ItemsSource,


//unitPrivate List{
List
Return UnitSheet;
}

//quality
Private List{
ListReturn QualityGauge;
}


//bind is where needed directly to a drop-down box ItemsSource assignment data query,
//a drop-down box on the page is like this but not in the form of binding, I also try to other method eventually fails,
////
UnitSheet=DanWei ();

////quality
QualityGauge=ZhiLiang ();



Here to query the database data as a drop-down,
Is not binding data, my goal is in the form binding drop-down boxes, drop-down box of the data from a database query data,

CodePudding user response:

Your DataContext DataGridComboBoxColumn here with the DataGrid DataContext is different, so you need to specified in DataGridComboBoxColumn DataContext
  • Related