Hello Everyone, I made a form (WPF User Control) with a textbox called Tracking_Num, a comboBox called Courier_List, and a button called Tracking_Button. The idea is the user selects a courier, enters the tracking number, and hits track to launch the default browser and track the package using the provided courier and tracking #.
The button is completely not working - nothing happens when I click it not even an error.
Here is my XML code:
<ComboBox x:Name="Courier_List" Margin="102,363.711,83,125.874" ItemsSource="{Binding Path=Courier_List, Mode=Default, UpdateSourceTrigger=PropertyChanged}" >
<ComboBoxItem x:Name="UPS" Content="UPS"/>
<ComboBoxItem x:Name="FedEX" Content="FedEX"/>
<ComboBoxItem x:Name="UPS_SCS" Content="UPS SCS"/>
</ComboBox>
<TextBox x:Name="Tracking_Num" Margin="102,393.2,83,96.237" Text="{Binding Path=Tracking_Num, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
<Button x:Name="Tracking_Button" Content="Track!" HorizontalAlignment="Left" Margin="284.6,393.2,0,0" VerticalAlignment="Top" Width="75" Height="24.8" Click="Tracking_Button_Click">
Here is my C# Code:
private void Tracking_Button_Click(object sender, RoutedEventArgs e)
{
switch (Courier_List.SelectedValue.ToString())
{
case "UPS":
System.Diagnostics.Process.Start("http://wwwapps.ups.com/ietracking/tracking.cgi?loc=CA_CA^&tracknum^=" + Tracking_Num.Text.ToString());
break;
case "FedEX":
System.Diagnostics.Process.Start("https://www.fedex.com/fedextrack/index.html?tracknumbers^=" + Tracking_Num.Text.ToString() + "^&locale=en_CA^&cntry_code=ca_english");
break;
case "UPS_SCS":
System.Diagnostics.Process.Start("https://www.upspostsaleslogistics.com/cfw/trackOrder.do?trackNumber^=" + Tracking_Num.Text.ToString());
break;
default:
break;
}
}
More Info: I am running SCSM 2012 R2 (the program this form is being imported into), my project is targeted at a 3.5 .Net framework (required by SCSM) being coded in Visual Studio 2013, and running the program while logged on under a Domain Administrator account.
UPDATE:
So I am pretty sure now that the problem is coming from the switch not recognizing a selection is being made or incorrectly passing it to selectedValue. Perhaps it is in the ToString method? What is the best way to pass the selection from comboBox to my switch?