Hello,
I have an image in my xaml as so:
<Image Name="TotalFloors" Width="98" Source="../Images/FloorOne.png" Margin="0 0 0 10" VerticalAlignment="Bottom" />
This is loading fine, however everything i have tried to get this image change in code has resulted in nothing being displayed.
I tried a MessageBox.Show(TotalFloors.Source.ToString()); and it returned:
pack://application:,,,/MyClient;component/Images/FloorOne.png
Which then prompted me to use this code:
private void GetFloorImg()
{
MessageBox.Show(TotalFloors.Source.ToString());
BitmapImage floorImage = new BitmapImage();
Uri uriSource;
switch (App.selectedBuilding.Floors)
{
case 1:
uriSource = new Uri("pack://application:,,,/MyClient;component/Images/FloorOne.png", UriKind.Absolute);
break;
case 2:
uriSource = new Uri("pack://application:,,,/MyClient;component/Images/FloorTwo.png", UriKind.Absolute);
break;
case 3:
uriSource = new Uri("pack://application:,,,/MyClient;component/Images/FloorThree.png", UriKind.Absolute);
break;
default :
throw new NotImplementedException();
}
floorImage.UriSource = uriSource;
TotalFloors.Source = floorImage;
}
However this is not working either. The images are all set to resource in the folder. And a breakpoint shows that my code is being hit.
Any Ideas? TIA, Kohan.