{"id":404,"date":"2017-01-13T12:50:51","date_gmt":"2017-01-13T12:50:51","guid":{"rendered":"https:\/\/ibex.tech\/windows-iot\/?p=404"},"modified":"2022-09-13T15:56:45","modified_gmt":"2022-09-13T14:56:45","slug":"using-combo-boxes-2","status":"publish","type":"post","link":"https:\/\/ibex.tech\/csharp\/uwp-programming-in-c\/combo-box-uwp-programming-in-c\/using-combo-boxes-2","title":{"rendered":".Using Combo Boxes"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code>\t&lt;ComboBox Canvas.Left=\"92\" Canvas.Top=\"150\"\n\t\tx:Name=\"MyComboBox\" \n\t\tHeader=\"My Combo Box\" \n\t&gt;&lt;\/ComboBox&gt;<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>\t\/\/----- SET UP COMBO BOXES -----\n\tMyComboBox.Items.Clear();\n\tMyComboBox.Items.Add(\"A\");\n\tMyComboBox.Items.Add(\"B\");\n\tMyComboBox.Items.Add(\"C\");\n\tMyComboBox.SelectedIndex = 0;<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Styled Example<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>  &lt;ComboBox Canvas.Left=\"92\" Canvas.Top=\"150\" x:Name=\"MyComboBox\" Style=\"{StaticResource cmbSetupRelays}\" \/&gt;<\/code><\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">In App.xaml<\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>        &lt;!-- COMBO BOX SETUP RELAYS --&gt;\n        &lt;Style x:Key=\"cmbSetupRelays\" TargetType=\"ComboBox\"&gt;\n            &lt;Setter Property=\"Width\" Value=\"178\" \/&gt;\n            &lt;Setter Property=\"Height\" Value=\"28\" \/&gt;\n            &lt;Setter Property=\"Background\" Value=\"LightGray\" \/&gt;\n            &lt;Setter Property=\"Foreground\" Value=\"#460000\"\/&gt;\n            &lt;Setter Property=\"BorderBrush\" Value=\"{ThemeResource SystemControlForegroundTransparentBrush}\" \/&gt;\n            &lt;Setter Property=\"BorderThickness\" Value=\"{ThemeResource ButtonBorderThemeThickness}\" \/&gt;\n            &lt;Setter Property=\"Padding\" Value=\"0,0,0,0\" \/&gt;\n            &lt;Setter Property=\"HorizontalAlignment\" Value=\"Center\" \/&gt;\n            &lt;Setter Property=\"VerticalAlignment\" Value=\"Center\" \/&gt;\n            &lt;Setter Property=\"FontFamily\" Value=\"Arial\" \/&gt;\n            &lt;Setter Property=\"FontWeight\" Value=\"Bold\" \/&gt;\n            &lt;Setter Property=\"FontSize\" Value=\"13\" \/&gt;\n            &lt;Setter Property=\"UseSystemFocusVisuals\" Value=\"True\" \/&gt;\n        &lt;\/Style&gt;<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Function call<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;ComboBox Canvas.Left=\"92\" Canvas.Top=\"150\" x:Name=\"MyComboBox\" SelectionChanged=\"EditComboBox_SelectionChanged\" \/&gt;<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>\tprivate async void EditComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)\n\t{\n\t\ttry\n\t\t{\n\t\t\t\/\/Get combobox name\n\t\t\tvar PageObject = sender as ComboBox;\n\n\t\t\t\/\/ = PageObject.SelectedIndex;\n\n\t\t}\n\t\tcatch (Exception ex)\n\t\t{\n\t\t\tSystem.Diagnostics.Debug.WriteLine(\"Exception: \" + ex.Message);\n\t\t}\n\t}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Styled Example In App.xaml Function call<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[148],"tags":[],"class_list":["post-404","post","type-post","status-publish","format-standard","hentry","category-combo-box-uwp-programming-in-c"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/404","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/comments?post=404"}],"version-history":[{"count":1,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/404\/revisions"}],"predecessor-version":[{"id":1196,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/404\/revisions\/1196"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/media?parent=404"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/categories?post=404"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/tags?post=404"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}