*Source code* If you don't want to write the code yourself, it's available here for 3$ (and free for Patreon supporters): www.patreon.com/OttoBotCode/shop/78705 Your support would be a massive help for me and my channel! 🤩
Hey bro can you help me i having problems with the ImageControls[r, c] = imageControls; it says that [] connot apply indexing an expression of type "image" error
Iam nowhere near this progress in my course about learning c#, but still went through the full video and did not only solve my understanding problem, but also learned tons of other things. Thank you very much!!
Absolutely Amazing Video! Comprehensive Use of WPF! Awesome! Excellent programming Practices! Going to Use Your Video in My College WinForms / WPF Programming Class as a Target to Aim for! Hope You Don't mind being the "Measurement Stick" of Expectation.
@@OttoBotCode When the End Screen is gonna appear, the fade in is disabled, and when i click Play Again, Fade in also Disabled in the Game Screen. Can you tell me how to fix it? Thanks for advance.
Hey! Can you please help me fix this error? (after you first build the project approx. 29:00) I try to build the project Error CS1061 'MainWindow' does not contain a definition for 'GameGrit_MouseDown' and no accessible extension method 'GameGrit_MouseDown' accepting a first argument of type 'MainWindow' could be found (are you missing a using directive or an assembly reference?) Thank you!
It cannot find the the MouseDown method in MainWindow.xaml.cs for some reason. You spelled "Grid" wrong ("Grit"). Maybe your method is called "GameGrid_MouseDown", but it is registered as "GameGrit_MouseDown" in the xaml. If this doesn't help, then send your entire project (zip or github link) to ottobotcodehelp@gmail.com, then I'll take a look 😊
hello i get a Compiler Error CS0116 at 24:00 at the line of code of" private readonly Dictionary imageSources = new () " how do I fix this? am I missing something
Hi I bought the game from you with x and a but I can't open it one or more projects in the solution were not loaded correctly . Please see the output window for details I don t know know how to solve this problem please help me
I can see where you are coming from but there's a good reason for doing it this way. When the event is invoked the event handler for it is called immediately. If we invoke the event before the if-else, the code in the event handler will see the wrong current player (it won't have been updated in time). If we invoke it after the if-else, the game ended event is invoked before the final move of the game, which is also bad. Hope that makes sense 😊
Awesome guide! Could you please help me with an error I encounter🙏? In the "ShowLine()" method on the lines: { Line.BeginAnimation(Line.X2Property, x2Animation); Line.BeginAnimation(Line.Y2Property, y2Animation); } I have a compile error: "(field) static readonly DependencyProperty System.Windows.Shapes.Line.X2Property Identifies the System.Windows.Shapes.Line.X2 dependency property. CS0176: Member 'Line.X2Property' cannot be accessed with an instance reference; qualify it with a type name instead" In my "MainWidnow" class I have the following imports: { using System.Windows; using System.Windows.Controls; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Media.Imaging; }
umm hi Otto what do i need use instead for private readonly Dictionary imageSources = (new)() the new doesnt work it says that i need hihger version 9.0 or greater
@@OttoBotCode is says this when i put the thing u sent me Severity Code Description Project File Line Suppression State Error CS1922 Cannot initialize type 'BitmapImage' with a collection initializer because it does not implement 'System.Collections.IEnumerable' C:\Users\Frej\source epos\Tic-Tac-Toe\Tic-Tac-Toe\MainWindow.xaml.cs 24 Error CS7036 There is no argument given that corresponds to the required formal parameter 'value' of 'Dictionary.Add(Player, ImageSource)' Tic-Tac-Toe C:\Users\Frej\source epos\Tic-Tac-Toe\Tic-Tac-Toe\MainWindow.xaml.cs 24 Active Error CS1922 Cannot initialize type 'BitmapImage' with a collection initializer because it does not implement 'System.Collections.IEnumerable' Tic-Tac-Toe C:\Users\Frej\source epos\Tic-Tac-Toe\Tic-Tac-Toe\MainWindow.xaml.cs 24 Active Error CS7036 There is no argument given that corresponds to the required formal parameter 'value' of 'Dictionary.Add(Player, ImageSource)' C:\Users\Frej\source epos\Tic-Tac-Toe\Tic-Tac-Toe\MainWindow.xaml.cs 23 Error CS7036 There is no argument given that corresponds to the required formal parameter 'value' of 'Dictionary.Add(Player, ImageSource)' C:\Users\Frej\source epos\Tic-Tac-Toe\Tic-Tac-Toe\MainWindow.xaml.cs 24 Error CS7036 There is no argument given that corresponds to the required formal parameter 'value' of 'Dictionary.Add(Player, ImageSource)' Tic-Tac-Toe C:\Users\Frej\source epos\Tic-Tac-Toe\Tic-Tac-Toe\MainWindow.xaml.cs 23 Active
Hi we had the same error and tried to fix it with your answer but there is an error code : CS1001 We don’t know what we did wrong, the rest is exactly like in the video
The coding is as follows: private readonly Dictionary imageSources = new Dictionary() { // Key value pairs here}; { ❌ { Player.X, new BitmapImage(new Uri("pack://application:,,,/Assets/X15.png" )) }, { Player.O, new BitmapImage(new Uri("pack://application:,,, /Assets/015.png"))} }; Where the emoji (❌) is set, there is the error with the code CS1001 (Identifier expected) Where is the mistake?
Hey Again! I liked the Snake game one so much that I decided to try another one! but I have run into another issue. it wont let me start the game like you did at 29:08 because its having trouble finding the files from the Uri thing you write at 24:05. I made sure I've typed everything right as far as I can tell.
Can you post the error you get when you start the program? Maybe your assets are not marked as resources (check 15:35). You can also copy-paste the URIs from the projects Github repository (link in description) to make sure they are right 😊
@@OttoBotCode The error only pops up when I try to run the game, and it highlights the URIs and says "Exception User-Unhandled System.IO.IOExeption: 'cannot locate recource 'assets/015.png'.'
@@OttoBotCode Oh I just figured out what went wrong, I seemed to have typed "015" instead of "O15" lol it works now, sorry for taking up your time lmao but thank you for being so helpful!
Maybe you accidentally created a "Class Library" or a "Console Application". Create a new project using the "WPF Application" template, that will add the App and MainWindow classes automatically. You can copy paste the code you've already written into this new project.
Hello, dude. Help me please: private void onMoveMade(int _row, int _column) { Player player = gameState.gameGrid[_row, _column]; imageControls[_row, _column].Source = imageSources[player]; PlayerImage.Source = imageSources[gameState.currentPlayer]; } it shows me: CS0103 The name "PlayerImage" does not exist in the current context. idk what i should to do. Check own and your code - everything is cool, not including my codestyle :( P.S. : Thank you for a video :3
You are very welcome 😀 Sounds like it cannot find anything with the name "PlayerImage". Perhaps you have called it something else in MainWindow.xaml? In my code I have this property on the Image control inside the TurnPanel: x:Name="PlayerImage" You should also have this. If you use a different name then you must use that name in the code-behind as well.
@@OttoBotCode OMG, dude... Thank you very much, you're the best!!! I just wrote CurrentPlayerImage and didn't notice it 😅. Also I want to say, that you have a the best tutorials on TH-cam!!! You explain very well. Dont't stop and keep it up! Good luck. You get a new subscriver, which will be wait your new videos))) P.S. : sorry for my, maybe, bad/uncorrect English, I just from Ukraine, so don't know English pretty well🙃
@@OttoBotCode Dude, I respect you for your code (async, await it's pretty good choice), but you violate SOLID rules, which I noticed. I'ma going to fix it and, maybe post on GitHub profile this project (I'll stay a link to this video). Don't you mind😬?
I typed this correctly: private readonly Dictionary imageSources = new() { { Player.X, new BitmapImage(new Uri("pack://application:,,,/Assets/X15.png")) }, { Player.O, new BitmapImage(new Uri("pack://application:,,,/Assets/O15.png")) }, }; but it gives me an error can you help?
Let me try to guess the problem. This line: private readonly Dictionary imageSources = new()... Would usually be written like this: private readonly Dictionary imageSources = new Dictionary()... I have omitted the type after the "new" keyword (I found it a little too verbose). This feature was introduced in C# 9, so if you are using an older version of C#, it won't work. Either use the "old" way where you explicitly write the type again after "new", or use C# version 9 or greater. I hope that solves the problem, otherwise just let me know.
*Source code*
If you don't want to write the code yourself, it's available here for 3$ (and free for Patreon supporters):
www.patreon.com/OttoBotCode/shop/78705
Your support would be a massive help for me and my channel! 🤩
Hey bro can you help me i having problems with the ImageControls[r, c] = imageControls; it says that [] connot apply indexing an expression of type "image" error
Respond Bro Need it Pls :)
Iam nowhere near this progress in my course about learning c#, but still went through the full video and did not only solve my understanding problem, but also learned tons of other things. Thank you very much!!
Absolutely Amazing Video! Comprehensive Use of WPF! Awesome! Excellent programming Practices! Going to Use Your Video in My College WinForms / WPF Programming Class as a Target to Aim for! Hope You Don't mind being the "Measurement Stick" of Expectation.
I have a full list of compilation errors if that helps you.
Great guide! I hope one day i will reach your level and beyond. :)
Thank you! You will for sure 😀
Hey Man! It's Just amazing
Keep it up!
You'll get your subscribers eventually!
Thank you 😃
@@OttoBotCode When the End Screen is gonna appear, the fade in is disabled, and when i click Play Again, Fade in also Disabled in the Game Screen.
Can you tell me how to fix it? Thanks for advance.
You're life saver bro, many thanks
So underrated!! You are amazing!
I appreciate it! Thanks alot 😉
Love it bro. Thanks for the help
Hey!
Can you please help me fix this error? (after you first build the project approx. 29:00) I try to build the project
Error CS1061 'MainWindow' does not contain a definition for 'GameGrit_MouseDown' and no accessible extension method 'GameGrit_MouseDown' accepting a first argument of type 'MainWindow' could be found (are you missing a using directive or an assembly reference?)
Thank you!
It cannot find the the MouseDown method in MainWindow.xaml.cs for some reason. You spelled "Grid" wrong ("Grit"). Maybe your method is called "GameGrid_MouseDown", but it is registered as "GameGrit_MouseDown" in the xaml.
If this doesn't help, then send your entire project (zip or github link) to ottobotcodehelp@gmail.com, then I'll take a look 😊
@@OttoBotCode LOOL, you have eagle eyes, I change the method to "Grit" and now is working. Thank you for taking the time and check my problem :)
@@SmallScaleFun That's what years of staring at code will do to you 😆 No problem, I'm glad it works!
@@OttoBotCode :)) I'm just starting to learn C# OOP and I was thinking that your project will be a good exercise. Thank you again for your time.
Great tutorial!
I need help with the Uri, 24:00, Ot doesn't locate my image. Anyone know how to find it.
hello i get a Compiler Error CS0116 at 24:00 at the line of code of" private readonly Dictionary imageSources = new () " how do I fix this? am I missing something
You are using an old version of C#. If you write the type again after new it should work:
private readonly Dictionary imageSources = new Dictionary()
Thank you
love the video!!
I want to add another Option to the Game To play Against CPU.
Can you help me with that??
Takk!
Det er mig som takker! 😀
man you are legend!
Hi
I bought the game from you with x and a but I can't open it
one or more projects in the solution were not loaded correctly .
Please see the output window for details
I don t know know how to solve this problem
please help me
13:57 You invoke the event in the if, and in the else statements. Is it a good solution? Maybe you should write invoke-command before the if-else?
I can see where you are coming from but there's a good reason for doing it this way.
When the event is invoked the event handler for it is called immediately.
If we invoke the event before the if-else, the code in the event handler will see the wrong current player (it won't have been updated in time).
If we invoke it after the if-else, the game ended event is invoked before the final move of the game, which is also bad.
Hope that makes sense 😊
@@OttoBotCode interesting, thank you
Amazing, thanks!
Thank you for the nice comment 😊
Good one. Thanks.
Glad you like it. Thanks for the comment 😄
Awesome guide!
Could you please help me with an error I encounter🙏? In the "ShowLine()" method on the lines:
{
Line.BeginAnimation(Line.X2Property, x2Animation);
Line.BeginAnimation(Line.Y2Property, y2Animation);
}
I have a compile error:
"(field) static readonly DependencyProperty System.Windows.Shapes.Line.X2Property
Identifies the System.Windows.Shapes.Line.X2 dependency property.
CS0176: Member 'Line.X2Property' cannot be accessed with an instance reference; qualify it with a type name instead"
In my "MainWidnow" class I have the following imports:
{
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
}
Already fixed it by adding:
{
using System.Windows.Shapes;
...
Line.BeginAnimation(Line.X2Property, x2Animation);
Line.BeginAnimation(Line.Y2Property, y2Animation);
}
Or alternatively:
{
using static System.Windows.Shapes.Line;
...
Line.BeginAnimation(X2Property, x2Animation);
Line.BeginAnimation(Y2Property, y2Animation);
}
am i able to email you about troubleshooting a roadblock a came across creating this?
It would be awesome thanks
How did you make your assets please ? They are clean.
They are made in Adobe Illustrator!
umm hi Otto what do i need use instead for private readonly Dictionary imageSources = (new)() the new doesnt work it says that i need hihger version 9.0 or greater
Hello! For older versions of C# you must write:
private readonly Dictionary imageSources = new Dictionary() {
// Key value pairs here
};
ty@@OttoBotCode
@@OttoBotCode is says this when i put the thing u sent me Severity Code Description Project File Line Suppression State
Error CS1922 Cannot initialize type 'BitmapImage' with a collection initializer because it does not implement 'System.Collections.IEnumerable' C:\Users\Frej\source
epos\Tic-Tac-Toe\Tic-Tac-Toe\MainWindow.xaml.cs 24
Error CS7036 There is no argument given that corresponds to the required formal parameter 'value' of 'Dictionary.Add(Player, ImageSource)' Tic-Tac-Toe C:\Users\Frej\source
epos\Tic-Tac-Toe\Tic-Tac-Toe\MainWindow.xaml.cs 24 Active
Error CS1922 Cannot initialize type 'BitmapImage' with a collection initializer because it does not implement 'System.Collections.IEnumerable' Tic-Tac-Toe C:\Users\Frej\source
epos\Tic-Tac-Toe\Tic-Tac-Toe\MainWindow.xaml.cs 24 Active
Error CS7036 There is no argument given that corresponds to the required formal parameter 'value' of 'Dictionary.Add(Player, ImageSource)' C:\Users\Frej\source
epos\Tic-Tac-Toe\Tic-Tac-Toe\MainWindow.xaml.cs 23
Error CS7036 There is no argument given that corresponds to the required formal parameter 'value' of 'Dictionary.Add(Player, ImageSource)' C:\Users\Frej\source
epos\Tic-Tac-Toe\Tic-Tac-Toe\MainWindow.xaml.cs 24
Error CS7036 There is no argument given that corresponds to the required formal parameter 'value' of 'Dictionary.Add(Player, ImageSource)' Tic-Tac-Toe C:\Users\Frej\source
epos\Tic-Tac-Toe\Tic-Tac-Toe\MainWindow.xaml.cs 23 Active
Hi we had the same error and tried to fix it with your answer but there is an error code : CS1001
We don’t know what we did wrong, the rest is exactly like in the video
The coding is as follows:
private readonly Dictionary imageSources = new Dictionary() { // Key value pairs here};
{ ❌
{ Player.X, new BitmapImage(new Uri("pack://application:,,,/Assets/X15.png" )) },
{ Player.O, new BitmapImage(new Uri("pack://application:,,, /Assets/015.png"))}
};
Where the emoji (❌) is set, there is the error with the code CS1001 (Identifier expected)
Where is the mistake?
Hey Again! I liked the Snake game one so much that I decided to try another one! but I have run into another issue. it wont let me start the game like you did at 29:08 because its having trouble finding the files from the Uri thing you write at 24:05. I made sure I've typed everything right as far as I can tell.
Can you post the error you get when you start the program? Maybe your assets are not marked as resources (check 15:35). You can also copy-paste the URIs from the projects Github repository (link in description) to make sure they are right 😊
@@OttoBotCode The error only pops up when I try to run the game, and it highlights the URIs and says "Exception User-Unhandled
System.IO.IOExeption: 'cannot locate recource 'assets/015.png'.'
@@SarcasticCupcake223 I think I need your project again. You know the drill 😆 I have a few minutes now so I can check it out!
@@OttoBotCode Oh I just figured out what went wrong, I seemed to have typed "015" instead of "O15" lol it works now, sorry for taking up your time lmao but thank you for being so helpful!
I don't have the app.xami folder, what do I do?
Maybe you accidentally created a "Class Library" or a "Console Application". Create a new project using the "WPF Application" template, that will add the App and MainWindow classes automatically. You can copy paste the code you've already written into this new project.
I have a bug the players are not switching so im only playing as X
May i know what to do to fix it
I should be able to find the problem if I could see your code. You can send your entire project (GitHub link is fine) to ottobotcodehelp@gmail.com 😀
@@OttoBotCode ok I sent it
30:54
Doesn't work, it asks if i want to install .NET but i already have .NET
Hello, dude. Help me please:
private void onMoveMade(int _row, int _column)
{
Player player = gameState.gameGrid[_row, _column];
imageControls[_row, _column].Source = imageSources[player];
PlayerImage.Source = imageSources[gameState.currentPlayer];
}
it shows me: CS0103 The name "PlayerImage" does not exist in the current context.
idk what i should to do. Check own and your code - everything is cool, not including my codestyle :(
P.S. : Thank you for a video :3
You are very welcome 😀
Sounds like it cannot find anything with the name "PlayerImage". Perhaps you have called it something else in MainWindow.xaml?
In my code I have this property on the Image control inside the TurnPanel:
x:Name="PlayerImage"
You should also have this. If you use a different name then you must use that name in the code-behind as well.
@@OttoBotCode OMG, dude... Thank you very much, you're the best!!! I just wrote CurrentPlayerImage and didn't notice it 😅.
Also I want to say, that you have a the best tutorials on TH-cam!!! You explain very well. Dont't stop and keep it up! Good luck. You get a new subscriver, which will be wait your new videos)))
P.S. : sorry for my, maybe, bad/uncorrect English, I just from Ukraine, so don't know English pretty well🙃
@@jiraffe8950 Thank you so much ☺ I really appreciate it 😀 And don't worry about me stopping, there is actually another C# project coming soon!
@@OttoBotCode Hurrah😂😂!!!
@@OttoBotCode Dude, I respect you for your code (async, await it's pretty good choice), but you violate SOLID rules, which I noticed. I'ma going to fix it and, maybe post on GitHub profile this project (I'll stay a link to this video). Don't you mind😬?
awesome video
I'm glad you like it 😀
I typed this correctly:
private readonly Dictionary imageSources = new()
{
{ Player.X, new BitmapImage(new Uri("pack://application:,,,/Assets/X15.png")) },
{ Player.O, new BitmapImage(new Uri("pack://application:,,,/Assets/O15.png")) },
};
but it gives me an error can you help?
I would love to try, can you tell me what kind of error you are getting?
Let me try to guess the problem.
This line:
private readonly Dictionary imageSources = new()...
Would usually be written like this:
private readonly Dictionary imageSources = new Dictionary()...
I have omitted the type after the "new" keyword (I found it a little too verbose). This feature was introduced in C# 9, so if you are using an older version of C#, it won't work. Either use the "old" way where you explicitly write the type again after "new", or use C# version 9 or greater.
I hope that solves the problem, otherwise just let me know.
@@OttoBotCode Thank you, i had same problem that fixed with this code