-1

Not able to show combo box value in ui which i was get in api.

<controls:DataGridTemplateColumn MinWidth="132" Header="Status" Tag="Status">
 <controls:DataGridTemplateColumn.CellTemplate>
     <DataTemplate>
         <StackPanel Orientation="Horizontal" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Margin="0">
             <ComboBox x:Name="cbx_Status" FontSize="10" MinHeight="29" Width="140" Background="Transparent" CornerRadius="0" BorderThickness="0" TabIndex="12"
                 ItemsSource="{Binding StatusList}"
                 SelectedValue="{Binding StatusDesc, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
                       KeyDown="cbx_Status_KeyDown" GettingFocus="cbx_Status_GettingFocus">

                 <ComboBox.ItemContainerStyle>
                     <Style TargetType="ComboBoxItem">
                         <Setter Property="Margin" Value="5 -8 0 0"/>
                         <Setter Property="FontSize" Value="11"/>
                         <Setter Property="FontWeight" Value="Normal"/>
                         <Setter Property="FocusVisualSecondaryBrush" Value="Transparent"/>
                         <Setter Property="FocusVisualPrimaryBrush" Value="Transparent"/>
                         <Setter Property="UseSystemFocusVisuals" Value="False"/>
                     </Style>
                 </ComboBox.ItemContainerStyle>
             </ComboBox>
         </StackPanel>
     </DataTemplate>
 </controls:DataGridTemplateColumn.CellTemplate>

</controls:DataGridTemplateColumn>

3
  • 1
    How does your grid's DataContext look like? You might want to check stackoverflow.com/questions/57616220/… too. Commented Sep 18, 2024 at 14:39
  • It might be easier to help with more code around the DataGrid, its ItemsSource and StatusList. Commented Sep 18, 2024 at 17:02
  • 2
    Also try to remove code and leave just the minimal code that reproduces the issue. Commented Sep 18, 2024 at 17:03

1 Answer 1

0

To make the UI automatically updated when you Binding in ItemsSource you need to use ObservableCollection

public ObservableCollection<object> StatusList { get; } = new();
Sign up to request clarification or add additional context in comments.

1 Comment

Already using observable collection. when i was click and select item and click another cell or column then its disappeared.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.