How to make a touchable notice top bar in windows phone ?
I am new to C# and windows phone world.So may be my question has a simple
way to solve,but I google a lot ,and didn't work out.
here is my purpose: I have a timer running throughout my app,it request a
service for notice info every one hour, and show a "notice bar" on the top of
screen.
it is easy to get the information ,but when I want to show them to the Page,
here is my problem:
1.
I used system tray to show my info.
It works,but then I found there is no touch or click event for Progress
Indication bar.
I even add an event to Touch.FrameReported in App.xaml.cs , but still ,
when i touch the system tray area, the event doesn't fire.
2.
Then I want to use a Dynamic way to achieve it: add a text block to the
current page
I got the current page handler ,but case I only know the current page
handler's type is PhoneApplicationPage, I can't get my Root UI element
(all my page has a root element named "LayoutRoot")
And when I try to use reflect method to get the "LayoutRoot" property,
the return value is null.
The code looks like this :
Type type = PhoneApplicationPageHandler.getType()<
//I checked,the type is my page's type
type.getProperty("LayoutRoot") or type.getField("LayoutRoot")
//they all return null
BTW: LayoutRoot is a grid, and it is described in my page's .xmal file.
Now My option is to make all my page inherit a defalut page ,in this page ,I will
implement a method to fulfill my second way to simulate a "touchable top bar".
but I think this coding is ugly .
So, can anyone tell me :
1.how to add touch event to a SystemTray
or
2.how to get a handler of an ui element which is described in xaml, while I only have a PhoneApplicationPage type handler of that page.
You may use
1) a toast prompt described here http://windowsphonegeek.com/articles/WP7-Toast-Prompt-in-depth
2)or shell toast described here http://www.c-sharpcorner.com/UploadFile/ae35ca/working-with-toast-notification-in%C2%A0windows-phone-7/ according to what suits your requirement the best. 3)You may also create a custom control which you may place on the top on your mainPage and handle its tap event accordingly.
Related
Pre-warning, I'm new to C# and XAML, but I'm really enjoying Windows 10 UWP apps. I've got a question on how to appropriately handle a SplitView.
I've got a Main Page, in which I have a SplitView control. In the SplitView Content, I've added a Frame for navigation to other pages. I want to add the Hamburger button on the child page to open the SplitView on the Main Page, but I can't access the SplitView control from the child page. How can I make the SplitView control accessible so that the hamburger button within the sub-page can open the SplitView pane?
The alternative is to add a header in the Main Page and have a static hamburger button there, but I don't like this option as it makes handling the text header content more difficult. Another is to copy the SplitView to each page. I don't want to do this either.
Any advice would be fantastic! Thank you.
I would highly recommend you take your alternative option of including the hamburger button in the main page. Users always expect it to be in the same location every time and changing this approach will probably result in a bad user experience.
You also don't want to be repeating code and thus you don't want to recreate the button on every page as well as any additional functionality like the open/close commands.
Rather than referencing elements from one page to another, a better practice is to keep things loosely coupled. This can be done with a messenger plugin which sends an event from one page to the other which can give it instructions on what you want to do. That way the other page only has to listen for the event instead of holding strong references. To streamline some of this process you could inherit from a base class which implements the messenger functionality.
That would provide a solution to your button and your header text situations but setting them up is out of the scope of this question. Depending on the size of you app and your goals, you might like to look into existing frameworks which helps in designing maintainable apps. A good Mvvm framework I would recommend checking out is MvvmCross which also cross platform and contains a messenger plugin.
Good luck with your app.
I found that solution :
In the MainPage, in your SplitView pane button method, add a SplitView reference as parameter in Navigate() :
private void SlitViewPaneButton_Tapped(object sender, TappedRoutedEventArgs e)
{
var frame = contentFrame;
Page page = frame?.Content as Page;
if (page?.GetType() != typeof(ChildPage))
{
frame.Navigate(typeof(ChildPage), SplitViewName);
}
}
In your ChildPage.xaml.cs :
protected override void OnNavigatedTo(NavigationEventArgs e)
{
SplitView sv = new SplitView();
sv = e.Parameter as NavigateControls;
}
You can now do sv.IsPaneOpen = false, in your ChildFrame code.
Note : if you want to pass several Controls, create a Class with these Controls as variables, and use an instance as parameter.
As stated above, it is better to keep your hamburger button in your main page for a couple of reasons. One is the consistency mentioned above. Second, you would have to recreate the hamburger button in each of your content pages instead of just once in the MainPage.xaml. Additionally, keep in mind, there are different kinds of interactions with the SplitView menu in terms of how it pops in and out and how it is displayed, all listed below.
Inline – When the menu pane is opened, it pushes the content over. When it’s closed, the content goes back to its original location
Overlay – When the menu pane is opened, it lays on top of the content. When it’s closed, it is invisible.
Compact Overlay – When the menu pane is opened, it lays on top of the content. When it’s closed, the pane is still visible in Compact Mode.
Compact Inline – When the menu pane is opened, it pushes the content over. When it’s closed, the content goes back to its original position but the pane is still visible in Compact Mode.
You can also see a quick intro into the SplitView here.
http://jamesqquick.com/windows-10-splitview-intro/
I'd like to write some code that fires when the layout details screen is opened. Is there an event, some sort of API or some way to hijack Sitecore UI to allow me to do this? There's nothing in the Sitecore.config events sectiont hat looks relevant.
What I want to do is capture the ID of the item for which I'm currently updating so that I can use it in custom controls later on.
I'm using Sitecore 6.6.
Marek Musielak's answer is great. An alternative would be to change the command fired from the 'Details' Button - Look for item:setlayoutdetails in the commands.config.
You could create your own class that does your work then instantiates Sitecore.Shell.Framework.Commands.SetLayoutDetails afterwards.
You can override the \sitecore\shell\Applications\Content Manager\Dialogs\LayoutDetails\LayoutDetails.xml and change its code beside:
<CodeBeside
Type="Sitecore.Shell.Applications.ContentManager.Dialogs.LayoutDetails.LayoutDetailsForm,Sitecore.Client"/>
to inherit from your custom class that will simply inherits from LayoutDetailsForm and overrides e.g. OnLoad method.
I use a page (named containerpage) with a ContentPresenter (named PageContent) and set its content to a PhoneApplicationPage instance (contentpage) in the page's OnNavigatedTo() eventhandler. I also have a mainpage with a button "Show Form". When I click on that button, the program navigates to the containerpage, that sets its contentpresenter's content to the contentpage. My problem is: if I click on "show form", then press the back button and click on "show form" again, I get ArgumentException with the text
"The parameter is incorrect"
on line
this.PageContent.Content = contentpage;
in the containerpage's OnNavigatedTo() eventhandler. I guess this is because I already set another ContentPresenter's Content to this contentpage (because navigating creates a new page), but if this is the problem, how can I unassign my contentpage from the previous ContentPresenter's Content?
As decyclone mentioned, your question would be a lot clearer with detailed code. That said, you might implement OnNavigatedFrom() on your conatinerpage and set the Content to null.
You might want to consider how this design holds up if the app gets tombstoned on containerpage.
To be honest, I'm amazed that setting the Content property of one page to be an instance of another page even works! I really would advise against that as a long term solution. If the content of the first page is dynamic based on some condition, then use different UserControls instead.
If the data for the UserControl is not persistent between calls to ShowForm, then you can just create a new instance each time and then you won't have the re-parenting problem.
If you can elaborate on your application scenario and what you are trying to achieve, then we might be able to provide a better answer.
I have created a UserControl using a DevExpress XtraTreeList. Basically in this user control I am using inventory Items. which are more than 30,000. Now when I load the complete table in my typed DataSet it takes almost 6-8 seconds.
The purpose to build the usercontrol is reuseability. So that we can use it in other parts of the application.
Now I am using this UserControl in a Winform, where this usercontrol is place in the left hand side on the form where it will be used as a Menu. The user is suppose to click its desired item by expanding the nodes and when the nodes is selected and then its further details will be fetched and will be displayed in the from. So far so good.
Now the reals issue is that in the same form along with other controls, we have a Devexpress XtraButtonEdit(build using a textbox and a button on the right handside). This buttonEdit is displaying the currently selected Item(from the treeMenu UserControl) code in its textbox, when we are clicking the buttonEdit button then we are loading another form as a model and displaying the same UserControl (XTRATreeList from DevEpress). The only issue is that when I am laoding this new form as a model. The tree again takes time to load which looks bit awkward.
To rectifiy this issue, I am trying to implement the Background worker thread, but bit confused that where should I implement that backgroundWork. In the User Control or in the form.
If I implement that Background worder in the UserControl then how can I access this BackgroundWorker thread and execute it on the main Form where I am using the UserControl on the left hand side as a Menu. Actually what I want is when user clicks the ButtonEdit control and the form loads, it should load like a flash or max in 2 sec....please help.... and execute it.
I hope that ppl will understand my issue.
If somebody finds any difficulty plz let me know....
Regards,
You don't have to "access this BackgroundWorker thread and execute it on the main Form".
A user control could contain its own Bgw. You nee a synchronous method (on the UC) to start it. Then handle the completed (and mayb progress) events inside your UC.
But the data won't load any faster, you only unfreeze your main GUI.
If the delay is caused in the code that loads the tree, then you should "thread" that part. I would recommend reading this sample chapter from C# in a Nutshell: http://www.albahari.com/threading/. They cover C# 4.0, but you should be able to apply most of the concepts to C# 3.0 if that's what you are using.
I've some questions .. and I really need your help.
I have an application.
First I display a splash screen, a form, and this splash would call another form.
Problem: When the splash form is displayed, if I then open another application on the top of the splash, and then minimize this newly opened application window, the splash screen becomes white. How do I avoid this? I want my splash to be displayed clearly and not affected by any application.
I'm using a DropDownList but I realized that there is 2 types of it . I found "Dropdown" which makes the text inside the DDL editable, and "DropDownList" which doesn't.
Problem: when I tried to use DropDownList control it doesn't allow me to add a default text while DropDown does so I want a DropDownList control which prevent modifying on the text and allow a default text .. what property should I use?
Can I add "?" which denotes to Help button to the FormBorder (with the minimization, maximization, and close buttons )
Can I change the colour of the Formborder from its default colour (blue) ?
One of my application functionality is to copy files from server to phone into a certain folder in memory card.
Problem : can I determine the free size of the MMC to notify the user if it's full while copying.
3) You have to set the "HelpButton" property of the form to true. However the "?" button is only visible if you deactivate the maximize and minimize buttons by setting "MinimizeBox" and "MaximizeBox" to false.
Here are a few...
1) you need to launch the window in another thread so that your app can do what it needs to do to start. When the startup finishes, signal to the splash screen that it can close itself.
2)
dropDownList.SelectedIndex = 0;
4) I would not recommend doing so. It is based on the system color scheme, which the user sets. I would not like an app to decide for itself which scheme to use.
5) if the MMC shows up as a mapped drive you could use one of these techniques
Once again there is no answer to this guys question.
Yes, do as the other guy said and launch the splash screen in its own thread.
There is only one type of ComboBox in .Net, However there is a property called DropDownStyle which sets its functionality.
Yes, I am clueless on how this one works and never needed it.
Yes you betcha, Its called non-client painting. you can find more info on it here http://www.codeplex.com/CustomerBorderForm/Wiki/View.aspx?title=Painting%20NonClient%20Area&referringTitle=Home
I Need more details on this.