I would like to know how to load an image externally url

  • Thread starter Thread starter EduardoAva
  • Start date Start date
E

EduardoAva

Guest
I would like to know how to load an image externally url


this code is loaded from xaml

<Button Name="StartGameBtn" HorizontalAlignment="Left" Margin="686,487,0,0" VerticalAlignment="Top" Width="180" Height="69" Background="{x:Null}" Click="StartGameBtn_Click" Grid.ColumnSpan="2" DataContext="{Binding}">
<Button.Template>
<ControlTemplate TargetType="{x:Type Button}">
<StackPanel>
<Image Name="Close2" Source="Resources/gamestart_hover.bmp" Stretch="Fill" Visibility="Collapsed" />
<Image Name="Close1" Source="Resources/gamestart.bmp" Stretch="Fill" Visibility="Visible" />
</StackPanel>
<ControlTemplate.Triggers>
<Trigger Property="UIElement.IsMouseOver" Value="True">
<Setter TargetName="Close2" Property="UIElement.Visibility" Value="Visible" />
<Setter TargetName="Close1" Property="UIElement.Visibility" Value="Collapsed" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Button.Template>
</Button>

I am trying to load the images externally url from xaml.cs
but I have not been able to achieve it.

try using this code

Uri uri = new Uri(AppDomain.CurrentDomain.BaseDirectory + strFormattedDate + @"\start.png", UriKind.RelativeOrAbsolute);
Close1.ImageSource = BitmapFrame.Create(uri);
but I don't have close1 reading, since it doesn't seem to exist to me
can you tell me what I'm doing wrong

the actual code is like this

demo.png


demo2.png


my question is how to make the call correctly as it marks in red as if it does not exist.

Continue reading...
 
Back
Top