I have a comboBox and I would like it when I select the date item it makes the datapick visible. How do I perform this operation?
I have a comboBox and I would like it when I select the date item it makes the datapick visible. How do I perform this operation?
Interpreting "visible datapick" as the selected item, one of the possibilities would be:
XAML
<ComboBox x:Name="ComboBoxOpcoes" SelectionChanged="ComboBoxOpcoes_OnSelectionChanged">
<ComboBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Width="Auto" Height="Auto">
<TextBlock Text="{Binding Tipo}"/>
</StackPanel>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
Code
public sealed partial class MainPage
{
public MainPage()
{
InitializeComponent();
var items = new ObservableCollection<Opcoes>();
var item = new Opcoes() { Tipo = "Opcao 1" };
items.Add(new Opcoes() { Tipo = "Opccao 2" });
items.Add(item);
items.Add(new Opcoes() { Tipo = "Outra opcao" });
ComboBoxOpcoes.ItemsSource = items;
ComboBoxOpcoes.SelectedItem = item;
}
private void ComboBoxOpcoes_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
{
var combo = (Windows.UI.Xaml.Controls.ComboBox)sender;
var item = (Opcoes)combo.SelectedItem;
Debug.Write($"selecionado: {item?.Tipo}");
}
}
public class Opcoes
{
public string Tipo { get; set; }
}