In Grid Resource am using
DataTemplate
with 2 combobox to shown workweek and year, I tried bind data in
combobox
but its not working , Please help me resolve this problem.
I tried combobox.content in cs file, there is no option to use combobox in cs.file
Not able to bind data in DataTemplate --
combobox wpf c#
What I have tried:
<Grid.Resources>
<!--DataTemplate for Published Date column defined in Grid.Resources. PublishDate is a property on the ItemsSource of type DateTime -->
<DataTemplate x:Key="DateTemplateAlpha" >
<StackPanel Width="100" Height="auto" Orientation="Horizontal">
<ComboBox Name="cmbAlphaYear" HorizontalAlignment="Left" VerticalAlignment="Top" Width="50" Height="18" FontSize ="15"
Background="FloralWhite" Text="Select Year"
ItemsSource="{Binding Path=DataContext.YearList, RelativeSource={RelativeSource AncestorType={x:Type Window}}}" DisplayMemberPath="Year" SelectedValuePath="Year"/>
<ComboBox Name="cmbAlphaWW" HorizontalAlignment="Left" VerticalAlignment="Top" Width="50" Height="18" FontSize ="15"
Background="FloralWhite" Text="Select WorkWeek"
DisplayMemberPath="skuName" SelectedValuePath="skuId"/>
</StackPanel>
</DataTemplate>
</Grid.Resources>
<datagrid x:name="dgData" autogeneratecolumns="False" margin="58,124,64,40" canuseraddrows="False">
<datagrid.columns>
<datagridtextcolumn header="Config" binding="{Binding Config}" isreadonly="True" width="*">
<datagridtemplatecolumn header="Alpha" x:name="Alpha" celltemplate="{StaticResource DateTemplateAlpha}" width="100">
<datagridtemplatecolumn header="Beta" x:name="Beta" celltemplate="{StaticResource DateTemplateBeta}" width="100">
<datagridtemplatecolumn header="PV" x:name="PV" celltemplate="{StaticResource DateTemplatePv}" width="100">