Cannot insert/locate find .png picture [duplicate]
up vote
0
down vote
favorite
This question already has an answer here:
Setting WPF image source in code
17 answers
Assign BitmapImage from Resources.resx to Image.Source?
1 answer
How to load image to WPF in runtime?
2 answers
I have found some code online that I can use on my own project. It's fairly simple, but when I run the program, I get an error message that it can not find the resource.
I have tried a lot and simply can not see the error - I inserted pictures by saying: add -> new folder (right click) -> added all the images:
int yourHandArray = yourHand.ToInt();
int dealerHandArray = dealerHand.ToInt();
for (int i = 0; i < yourHandArray.Length; i++)
{
switch (i)
{
case 0: Card1.Source = new BitmapImage(new Uri("pack://application:,,,/View/img_cards/"+ (yourHandArray[i] + 1) + ".png")); break;
case 1: Card2.Source = new BitmapImage(new Uri("pack://application:,,,/View/img_cards/" + (yourHandArray[i] + 1) + ".png")); break;
case 2: Card3.Source = new BitmapImage(new Uri("pack://application:,,,/View/img_Cards/" + (yourHandArray[i] + 1) + ".png")); break;
case 3: Card4.Source = new BitmapImage(new Uri("pack://application:,,,/View/img_cards/" + (yourHandArray[i] + 1) + ".png")); break;
case 4: Card5.Source = new BitmapImage(new Uri("pack://application:,,,/View/img_cards/" + (yourHandArray[i] + 1) + ".png")); break;
case 5: Card6.Source = new BitmapImage(new Uri("pack://application:,,,/View/img_cards/" + (yourHandArray[i] + 1) + ".png")); break;
case 6: Card7.Source = new BitmapImage(new Uri("pack://application:,,,/View/img_cards/" + (yourHandArray[i] + 1) + ".png")); break;
}
}
This is the folder I
refer to
c# wpf resources
marked as duplicate by Clemens
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
21 hours ago
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
|
show 9 more comments
up vote
0
down vote
favorite
This question already has an answer here:
Setting WPF image source in code
17 answers
Assign BitmapImage from Resources.resx to Image.Source?
1 answer
How to load image to WPF in runtime?
2 answers
I have found some code online that I can use on my own project. It's fairly simple, but when I run the program, I get an error message that it can not find the resource.
I have tried a lot and simply can not see the error - I inserted pictures by saying: add -> new folder (right click) -> added all the images:
int yourHandArray = yourHand.ToInt();
int dealerHandArray = dealerHand.ToInt();
for (int i = 0; i < yourHandArray.Length; i++)
{
switch (i)
{
case 0: Card1.Source = new BitmapImage(new Uri("pack://application:,,,/View/img_cards/"+ (yourHandArray[i] + 1) + ".png")); break;
case 1: Card2.Source = new BitmapImage(new Uri("pack://application:,,,/View/img_cards/" + (yourHandArray[i] + 1) + ".png")); break;
case 2: Card3.Source = new BitmapImage(new Uri("pack://application:,,,/View/img_Cards/" + (yourHandArray[i] + 1) + ".png")); break;
case 3: Card4.Source = new BitmapImage(new Uri("pack://application:,,,/View/img_cards/" + (yourHandArray[i] + 1) + ".png")); break;
case 4: Card5.Source = new BitmapImage(new Uri("pack://application:,,,/View/img_cards/" + (yourHandArray[i] + 1) + ".png")); break;
case 5: Card6.Source = new BitmapImage(new Uri("pack://application:,,,/View/img_cards/" + (yourHandArray[i] + 1) + ".png")); break;
case 6: Card7.Source = new BitmapImage(new Uri("pack://application:,,,/View/img_cards/" + (yourHandArray[i] + 1) + ".png")); break;
}
}
This is the folder I
refer to
c# wpf resources
marked as duplicate by Clemens
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
21 hours ago
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
Is the build action of the new files correctly set to "Resource"?
– Klaus Gütter
21 hours ago
1
Your code is far too complicated. Better put the Images elements in another array and writeCard[i].Source = new BitmapImage(...)
without the switch block. Besides that, make sure that the Build Action of the PNG files is set to Resource.
– Clemens
21 hours ago
Yes the build action of the new files er set to "Resources" but still cant be found.
– Kevin
20 hours ago
@Clemens That means I also have to change the XAML window and I can not see how to do that.
– Kevin
20 hours ago
Why exactly change the XAML? You can easily add Card1 to Card7 to an array. However, much better would be an ItemsControl with the Image element in its ItemTemplate.
– Clemens
20 hours ago
|
show 9 more comments
up vote
0
down vote
favorite
up vote
0
down vote
favorite
This question already has an answer here:
Setting WPF image source in code
17 answers
Assign BitmapImage from Resources.resx to Image.Source?
1 answer
How to load image to WPF in runtime?
2 answers
I have found some code online that I can use on my own project. It's fairly simple, but when I run the program, I get an error message that it can not find the resource.
I have tried a lot and simply can not see the error - I inserted pictures by saying: add -> new folder (right click) -> added all the images:
int yourHandArray = yourHand.ToInt();
int dealerHandArray = dealerHand.ToInt();
for (int i = 0; i < yourHandArray.Length; i++)
{
switch (i)
{
case 0: Card1.Source = new BitmapImage(new Uri("pack://application:,,,/View/img_cards/"+ (yourHandArray[i] + 1) + ".png")); break;
case 1: Card2.Source = new BitmapImage(new Uri("pack://application:,,,/View/img_cards/" + (yourHandArray[i] + 1) + ".png")); break;
case 2: Card3.Source = new BitmapImage(new Uri("pack://application:,,,/View/img_Cards/" + (yourHandArray[i] + 1) + ".png")); break;
case 3: Card4.Source = new BitmapImage(new Uri("pack://application:,,,/View/img_cards/" + (yourHandArray[i] + 1) + ".png")); break;
case 4: Card5.Source = new BitmapImage(new Uri("pack://application:,,,/View/img_cards/" + (yourHandArray[i] + 1) + ".png")); break;
case 5: Card6.Source = new BitmapImage(new Uri("pack://application:,,,/View/img_cards/" + (yourHandArray[i] + 1) + ".png")); break;
case 6: Card7.Source = new BitmapImage(new Uri("pack://application:,,,/View/img_cards/" + (yourHandArray[i] + 1) + ".png")); break;
}
}
This is the folder I
refer to
c# wpf resources
This question already has an answer here:
Setting WPF image source in code
17 answers
Assign BitmapImage from Resources.resx to Image.Source?
1 answer
How to load image to WPF in runtime?
2 answers
I have found some code online that I can use on my own project. It's fairly simple, but when I run the program, I get an error message that it can not find the resource.
I have tried a lot and simply can not see the error - I inserted pictures by saying: add -> new folder (right click) -> added all the images:
int yourHandArray = yourHand.ToInt();
int dealerHandArray = dealerHand.ToInt();
for (int i = 0; i < yourHandArray.Length; i++)
{
switch (i)
{
case 0: Card1.Source = new BitmapImage(new Uri("pack://application:,,,/View/img_cards/"+ (yourHandArray[i] + 1) + ".png")); break;
case 1: Card2.Source = new BitmapImage(new Uri("pack://application:,,,/View/img_cards/" + (yourHandArray[i] + 1) + ".png")); break;
case 2: Card3.Source = new BitmapImage(new Uri("pack://application:,,,/View/img_Cards/" + (yourHandArray[i] + 1) + ".png")); break;
case 3: Card4.Source = new BitmapImage(new Uri("pack://application:,,,/View/img_cards/" + (yourHandArray[i] + 1) + ".png")); break;
case 4: Card5.Source = new BitmapImage(new Uri("pack://application:,,,/View/img_cards/" + (yourHandArray[i] + 1) + ".png")); break;
case 5: Card6.Source = new BitmapImage(new Uri("pack://application:,,,/View/img_cards/" + (yourHandArray[i] + 1) + ".png")); break;
case 6: Card7.Source = new BitmapImage(new Uri("pack://application:,,,/View/img_cards/" + (yourHandArray[i] + 1) + ".png")); break;
}
}
This is the folder I
refer to
This question already has an answer here:
Setting WPF image source in code
17 answers
Assign BitmapImage from Resources.resx to Image.Source?
1 answer
How to load image to WPF in runtime?
2 answers
c# wpf resources
c# wpf resources
edited 20 hours ago
asked 21 hours ago
Kevin
13
13
marked as duplicate by Clemens
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
21 hours ago
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by Clemens
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
21 hours ago
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
Is the build action of the new files correctly set to "Resource"?
– Klaus Gütter
21 hours ago
1
Your code is far too complicated. Better put the Images elements in another array and writeCard[i].Source = new BitmapImage(...)
without the switch block. Besides that, make sure that the Build Action of the PNG files is set to Resource.
– Clemens
21 hours ago
Yes the build action of the new files er set to "Resources" but still cant be found.
– Kevin
20 hours ago
@Clemens That means I also have to change the XAML window and I can not see how to do that.
– Kevin
20 hours ago
Why exactly change the XAML? You can easily add Card1 to Card7 to an array. However, much better would be an ItemsControl with the Image element in its ItemTemplate.
– Clemens
20 hours ago
|
show 9 more comments
Is the build action of the new files correctly set to "Resource"?
– Klaus Gütter
21 hours ago
1
Your code is far too complicated. Better put the Images elements in another array and writeCard[i].Source = new BitmapImage(...)
without the switch block. Besides that, make sure that the Build Action of the PNG files is set to Resource.
– Clemens
21 hours ago
Yes the build action of the new files er set to "Resources" but still cant be found.
– Kevin
20 hours ago
@Clemens That means I also have to change the XAML window and I can not see how to do that.
– Kevin
20 hours ago
Why exactly change the XAML? You can easily add Card1 to Card7 to an array. However, much better would be an ItemsControl with the Image element in its ItemTemplate.
– Clemens
20 hours ago
Is the build action of the new files correctly set to "Resource"?
– Klaus Gütter
21 hours ago
Is the build action of the new files correctly set to "Resource"?
– Klaus Gütter
21 hours ago
1
1
Your code is far too complicated. Better put the Images elements in another array and write
Card[i].Source = new BitmapImage(...)
without the switch block. Besides that, make sure that the Build Action of the PNG files is set to Resource.– Clemens
21 hours ago
Your code is far too complicated. Better put the Images elements in another array and write
Card[i].Source = new BitmapImage(...)
without the switch block. Besides that, make sure that the Build Action of the PNG files is set to Resource.– Clemens
21 hours ago
Yes the build action of the new files er set to "Resources" but still cant be found.
– Kevin
20 hours ago
Yes the build action of the new files er set to "Resources" but still cant be found.
– Kevin
20 hours ago
@Clemens That means I also have to change the XAML window and I can not see how to do that.
– Kevin
20 hours ago
@Clemens That means I also have to change the XAML window and I can not see how to do that.
– Kevin
20 hours ago
Why exactly change the XAML? You can easily add Card1 to Card7 to an array. However, much better would be an ItemsControl with the Image element in its ItemTemplate.
– Clemens
20 hours ago
Why exactly change the XAML? You can easily add Card1 to Card7 to an array. However, much better would be an ItemsControl with the Image element in its ItemTemplate.
– Clemens
20 hours ago
|
show 9 more comments
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Is the build action of the new files correctly set to "Resource"?
– Klaus Gütter
21 hours ago
1
Your code is far too complicated. Better put the Images elements in another array and write
Card[i].Source = new BitmapImage(...)
without the switch block. Besides that, make sure that the Build Action of the PNG files is set to Resource.– Clemens
21 hours ago
Yes the build action of the new files er set to "Resources" but still cant be found.
– Kevin
20 hours ago
@Clemens That means I also have to change the XAML window and I can not see how to do that.
– Kevin
20 hours ago
Why exactly change the XAML? You can easily add Card1 to Card7 to an array. However, much better would be an ItemsControl with the Image element in its ItemTemplate.
– Clemens
20 hours ago