C
C#2y ago
itgel9462

✅ WPF

(asking again) Can I refer cs file in xaml.cs? if so, how
52 Replies
ero
ero2y ago
What do you mean? You don't generally "refer" to other source files.
itgel9462
itgel9462OP2y ago
There are XAML file and its code behind. I want to refer other class in it. Oh, Is it not referring 😅 I mean, I want to add the class method in xaml.cs file or call out the xaml.cs in class
ero
ero2y ago
I mean, just as you would in any other project? Has nothing to do with wpf Add a using directive for the namespace the other class is in, and then just use it
itgel9462
itgel9462OP2y ago
all of them are in same project.
ero
ero2y ago
I'm saying it doesn't matter if it's WPF, or WinForms, or a Console app, or just a class library Accessing classes in other files always works the same
itgel9462
itgel9462OP2y ago
Sorry. I'm new to this language. Could you explain it more clearly. I called this class1 in Mainwindow.xaml.cs directly and got error. If I called this class1 in Class2 (just to make sure if it works) and it worked.
ero
ero2y ago
What error
itgel9462
itgel9462OP2y ago
itgel9462
itgel9462OP2y ago
Here is how I called the class in Mainwindow.xaml.cs
ero
ero2y ago
That doesn't really have anything to do with it being in another file You're doing everything right, it's an issue with the SpeechRecognizer class
itgel9462
itgel9462OP2y ago
I'm running this class only and getting speech recognition result. I don't think it's a problem of this class.
ero
ero2y ago
It quite obviously is an issue with SpeechRecognizer That's the line that throws So look up what SPXERR_AUDIO_SYS_LIBRARY_NOT_FOUND means
itgel9462
itgel9462OP2y ago
SPXERR_AUDIO_SYS_LIBRARY_NOT_FOUND was only in python. Solution was to delete another version of python.
ero
ero2y ago
It quite clearly is not only in python
itgel9462
itgel9462OP2y ago
I guess so.
sibber
sibber2y ago
you probably shouldnt be creating an instance every time but thats unrelated to the issue
itgel9462
itgel9462OP2y ago
There are 2 different methods though. Is that bad btw
sibber
sibber2y ago
if the other one works then use that theres probably something wrong in your config
itgel9462
itgel9462OP2y ago
Do you mean if I create 2 methods in 1 button, It would crack?
sibber
sibber2y ago
no im saying if SpeechConfig.FromSubscription works, then use that rather than the ctor oh wait, thats just a config are you sure your api key is correct also use Task.Run rather than instantiating a task
itgel9462
itgel9462OP2y ago
I changed api key for SS.
sibber
sibber2y ago
ik try the speech recognizer in new blank console app with a simple example
itgel9462
itgel9462OP2y ago
do you mean the whole class
sibber
sibber2y ago
wdym
itgel9462
itgel9462OP2y ago
sorry. what do you mean by that
sibber
sibber2y ago
new blank app
itgel9462
itgel9462OP2y ago
I didn't get that sorry.
sibber
sibber2y ago
just to test the speech recognizer no gui
itgel9462
itgel9462OP2y ago
as an class right?
sibber
sibber2y ago
to eliminate other variables what do you mean
itgel9462
itgel9462OP2y ago
I meant whole class is this.
itgel9462
itgel9462OP2y ago
did you mean this source code or just line 25?
HowNiceOfYou
HowNiceOfYou2y ago
Is this resolved or can I help?
sibber
sibber2y ago
just test SpeechRecognizer
itgel9462
itgel9462OP2y ago
not yet. wow. I'm sorry I really thought it's impossible. I'll try it
HowNiceOfYou
HowNiceOfYou2y ago
Can I ask, what exactly are you attempting to create?
sibber
sibber2y ago
TLDR ^
itgel9462
itgel9462OP2y ago
XAML is for frame. in xaml.cs, I reference eye tracking API to get gazing point and declared in it. And the class1.cs is to get real time speech recognition. Is that clear?
HowNiceOfYou
HowNiceOfYou2y ago
Yeah I sort of understand it, what's the issue exactly? Can you send me your code that's having it and you want changed?
itgel9462
itgel9462OP2y ago
How should I send you? Is screenshot ok?
HowNiceOfYou
HowNiceOfYou2y ago
Well first can you tell me the problem, then just send it in a txt format.
itgel9462
itgel9462OP2y ago
I tried to call the class1.cs which is get speech recognition as a result string in Mainwindow.xaml.cs. But I got a error. the error is here So, What I thought is, the problem is that I'm trying to call the class1.cs in xaml.cs file
HowNiceOfYou
HowNiceOfYou2y ago
I've never worked with speech recognition so I can't give you any tips, sorry man.
itgel9462
itgel9462OP2y ago
ohh I see It's okay thank you But I think the problem is not in speech recognition class.
ero
ero2y ago
Yes it is It so obviously is
itgel9462
itgel9462OP2y ago
I'm really wonder why it's working if I call it in other class
sibber
sibber2y ago
where is it working
ero
ero2y ago
Crystal ball out of order
itgel9462
itgel9462OP2y ago
Thank you guys. If have another advice please let me know.
ero
ero2y ago
The advice is to post the code where you're saying it works
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server