WP菜单和按钮 [英] WP Menu and Buttons

查看:143
本文介绍了WP菜单和按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我仍然是一名学生(大学四年级),我曾在C#工作过很多,但直到最近才知道WPF的可能性.我最近一个月左右一直在使用WPF.我对WPF的兴趣是开发可在触摸屏上使用的应用程序.

我对开发用于娱乐场所的可触摸应用程序的想法.

1.该应用程序将包含许多我已经开发的较小的应用程序. (例如,浏览器,photoviewer,facebook,邮件....)现在,我需要将所有这些小apss/windows链接在一起.现在,我希望得到指导,确定执行此操作的最佳做​​法是什么.

http://i46.tinypic.com/1zpqv6t.jpg

我在这里计划的是有一个带有3个图像按钮的欢迎屏幕作为主菜单,每个菜单都会有其他项目,依此类推.最多可以单击5次以转到较小的应用程序.我该如何构建?原因我真的不知道从哪里开始,我是使用多个窗口还是使用不同的面板?



2.我的菜单之一将包含动态按钮,因为它将是从数据库中检索到的可供出售产品的列表.现在我需要这些按钮成为图像按钮.

当前,我有以下代码:(MenuName是项目中已经存在的图像的名称)

< Window.Resources>
< ControlTemplate x:Key ="btnTemplate" TargetType ="{x:Type Button}">
< Image x:Name ="Image1" Source ="{Binding MenuName}"/>
</ControlTemplate>
</Window.Resources>

-------------------------------------------------- ---------------------
字符串MenuName;

私有void addChildren()
{
Window1 window1 = new Window1();
样式buttonStyle = window1.Resources ["btnTemplate"]作为样式;

foreach(数据库中的项目)
{
Button btn = new Button();
btn.Name ="btnProduct" + item;
btn.Style = buttonStyle;
MenuName =菜单" + item +.png";
btn.Click + = new RoutedEventHandler(buttonClick);
MainGrid.Children.Add(btn);
}
}

私人void buttonClick(object sender,EventArgs e)
{
按钮btn =(按钮)发送器;
MessageBox.Show(这是产品" + btn.Name);
}



atm我正在捕获此异常< b>在PresentationFramework.dll</b>中发生了类型为"System.StackOverflowException"的未处理异常,并将其抛出到构造函数中.有帮助吗?

Hi,

I''m still a student (4th year univ) and I''ve worked alot with C# but only recently came to know the possibilities of WPF. I''ve been using WPF for the last month or so now. My interest in WPF is that for developing Applications which can be used on touch screens.

My idea for what I''m developing a Touchable Application to be used in recreational areas.

1. The app will consist of many smaller apps which i have many already developed. (ex. browser, photoviewer, facebook, mail ....) Now I need to link all theses small apss/windows all together. Now I wish to be kindly directed what is the best practice to do this.

http://i46.tinypic.com/1zpqv6t.jpg

What I''m planning here is to have a welcome screen with 3 image buttons as a Main Menu, Each Menu will have other items and so on. There can as much as 5 clicks to get to the smaller app. How do I build this? Cause I really have no idea where to start, do i use multiple windows or use different Panels?



2. One of my menus will contain dynamic buttons as it will be a list of products available for sale retrieved from the database. Now I need these buttons to be image buttons.

currently I have this code: (MenuName is the name of the image already in the project)

<Window.Resources>
<ControlTemplate x:Key="btnTemplate" TargetType="{x:Type Button}">
<Image x:Name="Image1" Source="{Binding MenuName}"/>
</ControlTemplate>
</Window.Resources>

-----------------------------------------------------------------------
string MenuName;

private void addChildren()
{
Window1 window1 = new Window1();
Style buttonStyle = window1.Resources["btnTemplate"] as Style;

foreach (item in database)
{
Button btn = new Button();
btn.Name = "btnProduct"+item;
btn.Style = buttonStyle;
MenuName = "menu"+item+".png";
btn.Click += new RoutedEventHandler(buttonClick);
MainGrid.Children.Add(btn);
}
}

private void buttonClick(object sender, EventArgs e)
{
Button btn = (Button)sender;
MessageBox.Show("this is product " + btn.Name);
}



atm I''m catching this exception <b>An unhandled exception of type ''System.StackOverflowException'' occurred in PresentationFramework.dll </b>and it''s thrown in the constructor. Any help?

推荐答案

Xihadd写道:

现在我需要链接所有这些内容小apss/windows在一起.现在,我希望得到指导,确定执行此操作的最佳做​​法是什么.

Now I need to link all theses small apss/windows all together. Now I wish to be kindly directed what is the best practice to do this.



我猜有一个中央应用程序可以运行它们,并在它们运行时位于它们后面




I guess have a central app that runs them and sits behind them as they run


Xihadd写道:

最多可以点击5次以转到较小的应用.我该如何构建?原因我真的不知道从哪里开始,我是使用多个窗口还是使用不同的面板?

There can as much as 5 clicks to get to the smaller app. How do I build this? Cause I really have no idea where to start, do i use multiple windows or use different Panels?



我建议您对每个菜单步骤都具有控件,并根据先前的选择显示不同的控件.




I would suggest that you have controls for each menu step and show a different control based on the prior selection.


Xihadd写道:

Window1 window1 = new Window1();

Window1 window1 = new Window1();



为什么?




Why ?


Xihadd写道:

atm我正在捕获此异常 PresentationFramework中发生了类型为"System.StackOverflowException"的未处理异常. dll 并将其抛出到构造函数中.有帮助吗?

atm I''m catching this exception An unhandled exception of type ''System.StackOverflowException'' occurred in PresentationFramework.dll and it''s thrown in the constructor. Any help?



猜测一下,构造函数将调用addChildren,并且该类是Window1.因此,每个构造函数都调用一个方法,该方法创建一个Window1的新实例,因此它会递归直到崩溃.

如果那不是答案,我们将不得不寻求构造函数的帮助.



At a guess, the constructor calls addChildren, and the class is Window1. So, each constructor, calls a method that creates a new instance of Window1, so it recurses until it blows up.

We''d have to see the constructor to help if that''s not the answer.


这篇关于WP菜单和按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆