I have been following this tutorial about "How to: Preserve and Restore Page State for Windows Phone" found at http://goo.gl/ct7ui and one of the lines of code is this:
protected override void OnNavigatedFrom(System.Windows.Navigation.NavigationEventArgs e)
{
// If this is a back navigation, the page will be discarded, so there
// is no need to save state.
if (e.NavigationMode != System.Windows.Navigation.NavigationMode.Back)
{
// Save the ViewModel variable in the page's State dictionary.
State["ViewModel"] = _viewModel;
}
}
However visual studio does not seem to like this bit of code giving me the error below:
'System.Windows.Navigation.NavigationEventArgs' does not contain a definition for 'NavigationMode' and no extension method 'NavigationMode' accepting a first argument of type 'System.Windows.Navigation.NavigationEventArgs' could be found (are you missing a using directive or an assembly reference?)
Any ideas on what i've messed up with here. Now considering 'e' is System.Windows.Navigation.NavigationEventArgs and the bit after the if statement shows System.Windows.Navigation.NavigationMode.Back, i don't for the life of me see how this is giving an error
NavigationMode is an enum in System.Windows.Navigation. Try adding
using System.Windows.Navigation;
Related
So I am using the Plugin.SpeechRecognition Nuget Package and following the exact code on line and its not working.
I have tried adding the "Plugin.Permissions" Nuget Package and that hasn't helped and i have tried googling the problem but there isn't anyone getting this issue and it seems to work fine for everyone. I have also tried removing the "await" keyword and it just says
Operator '==' cannot be applied to operands of type 'IObservable' and 'bool'
Here is my code:
private async void GetSpeechPermission()
{
var granted = await CrossSpeechRecognition.Current.RequestPermission();
if (granted == true)
{
// go!
}
}
so what should happen is there is no error what so ever and the code should run fine but the line of code
await CrossSpeechRecognition.Current.RequestPermission();
has a red underline saying
IObservable' does not contain a definition for 'GetAwaiter' and no extension method 'GetAwaiter' accepting a first argument of type 'IObservable' could be found (are you missing a using directive or an assembly reference?)
when I am using the EXACT code provided by the creator of the plugin from here https://github.com/aritchie/speechrecognition
Any help is MUCH appreciated!!
The Solution to this was to add
using System.Reactive.Linq
in the using section of the code and instead of using a bool value as the code example for the plugin suggests, instead, in the if statement, convert the "granted" variable to a string and then check for "Available", Code:
private async void GetSpeechPermission()
{
var granted = await CrossSpeechRecognition.Current.RequestPermission();
if (granted.ToString() == "Available")
{
//GO
}
}
Hope this helps some one! :D
I am working on a UWP application and I am trying to do something with the values of a SelectedItem in a GridView. So as I usually do with WPF I went into the XAML and Typed my event name in the XAML and let VS create the event in code for me.
<GridView x:Name="DataGrid1"
ItemClick="dg_ItemClick">
<!-- Just -->
<!-- Some -->
<!-- Normal -->
<!-- XAML -->
</GridView>
and the VS created event looks like this
private void dg_ItemClick(object sender, Windows.UI.Xaml.Controls.ItemClickEventArgs e)
{
Biz.Customer cust = e.ClickedItem as Biz.Customer;
var messageDialog2 = new MessageDialog(cust.Code, cust.Company);
messageDialog2.ShowAsync();
}
Right away I get a red squiggly line under the UI in the Windows.UI.Xaml.Controls part. There is a using at the top of the page to include that and VS wouldn't let add any other UWP references.
I can get the error to go away as I have in other parts of the application by changing the ItemClickEventArgs to RoutedEvenArgs but in this case I really need the ClickedItem as an argument to be passed to the code behind.
I have just talked to someone else getting started with UWP and they said they are having the same issue on other cLick events. So are we both doing something wrong or is there something missing from our application that is needed for the UI to be recognized?
The full error I am getting is this: Error CS0234 The type or namespace name 'UI' does not exist in the namespace 'app name' (are you missing an assembly reference?)
The type or namespace name 'UI' does not exist in the namespace 'app name'
That means you have a namespace in your app that contains Windows.
Either change your namespace, or prefix the UWP one:
global::Windows.UI.Xaml.Controls
See also How to: Use the Global Namespace Alias (C# Programming Guide).
One of bugs I can see is that your handler should be marked async, also you should use await operator when you call async method:
private async void dg_ItemClick(object sender, Windows.UI.Xaml.Controls.ItemClickEventArgs e)
{
Biz.Customer cust = e.ClickedItem as Biz.Customer;
var messageDialog2 = new MessageDialog(cust.Code, cust.Company);
await messageDialog2.ShowAsync();
}
i trying to call a form as show dialog in in main coding
i have added below screen shot to help you guys under what i am asking. I have tried search on the internet but wasn't able to find a solution too.
but itemsDeleteScreen,itemsEditScreen and AddScreens works perfectly
image screenshot - http://i.stack.imgur.com/E66du.png
the items DeleteScreen Code : (Which Works)
itemsDeleteScreen deleteItem = new itemsDeleteScreen();
deleteItem.ShowDialog(this); // loads the Delete Items Screen
the StockInsScreen Code : (Whic Does not Work)
stockInsScreen stkIns = new stockInsScreen();
stockInsScreen.ShowDialog(this);
the error which i getting when i compile is
The type or namespace name 'stockInsScreen' could not be found (are you missing a using directive or an assembly reference?)
Navigate to StockInScreen Class and check the namespace, it would be like(yourproject.foldername) and add that name space in the class you want to use.(Source:From Image you have provided).For information about namespace,look at http://msdn.microsoft.com/en-us/library/z2kcy19k.aspx
Has anyone ran into problem where you just can't use the PageOrientation property in your C# WPF project? I have tried everything, put it still says:
"The name 'PageOrientation' does not exist in the current context".
I have all usings included, just can't figure it out.
Here's my printing method:
private void btnPrindi_Click(object sender, RoutedEventArgs e)
{
PrintDialog prtDlg = new PrintDialog();
if (prtDlg.ShowDialog() == true)
{
**prtDlg.PrintTicket.PageOrientation = PageOrientation.Landscape;**
Size pageSize = new Size(prtDlg.PrintableAreaWidth - 30, prtDlg.PrintableAreaHeight - 30);
gridKaart.Measure(pageSize);
gridKaart.Arrange(new Rect(15,15,pageSize.Width,pageSize.Height));
prtDlg.PrintVisual(gridKaart,"Patsiendikaart");
}
}
The error actually refers to the enumeration (PageOrientation.Landscape) on the right hand side of your assignment.
If the property did not exist you would receive (try compiling "".Y and you'll see what I mean):
'string' does not contain a definition for 'Y' and no extension method 'Y' accepting a first argument of type 'string' could be found (are you missing a using directive or an assembly reference?)
Compare this to Aoeui.Dhtns:
The name 'Aoeui' does not exist in the current context
You are likely missing a namespace reference required, like System.Printing:
// ...
using System.Printing;
// ...
The other possibility is you have not referenced ReachFramework.
If you have, your code compiles as-is:
on a MainPage, I have a button which could take me to another page.
private void button_clicked(object sender, Windows.UI.Xaml.RoutedEventArgs e)
{
if (this.Frame != null)
{
this.Frame.Navigate(typeof(AnotherPage));
}
}
However, it gives me this error:
Error 1 'test.CreateAccountPage' does not contain a definition for 'button_createAccount_clicked' and no extension method 'button_createAccount_clicked' accepting a first argument of type 'test.CreateAccountPage' could be found (are you missing a using directive or an assembly reference?) C:\Users\Anggrian\Documents\Visual Studio 2012\Projects\test\test\CreateAccountPage.xaml 55 98
I swear to God it worked yesterday, now I am clueless
Try going to line 55 in C:\Users\Anggrian\Documents\Visual Studio 2012\Projects\test\test\CreateAccountPage.xaml and replace button_createAccount_clicked with button_clicked