所以我在注册页面中有这个空的文本框.用户输入一些数据,点击继续,然后有一个确认页面.如果数据不正确,用户点击返回去纠正错误.但是,当他回去时,所有文本框都是空的.所以我想到的第一件事就是将用户数据存储在一个Session中(我有一个User类,它包含所有这些数据,因此我将该类存储在会话中).当用户返回时,我能够检索数据.
我做这样的事情:
if($_SESSION['UserInfo'])
{
$user = $_SESSION['UserInfo'];
$firstName = $user->FirstName;
$lastName = $user->LastName;
}
Run Code Online (Sandbox Code Playgroud)
我如何将这些变量放在文本框中?
这是事情:
object[] arrayText = new object[1];
if (arrayText[1] == null)
{
MessageBox.Show("Is null");
}
Run Code Online (Sandbox Code Playgroud)
我们知道这将是null,但它抛出一个异常,但我不想在try/catch块中处理它,因为它嵌套在循环中,try/catch会降低它的速度,它也不会看起来真的很棒:
object[] arrayText = new object[1];
try
{
if (arrayText[1] == null)
{
}
}
catch (Exception ex)
{
MessageBox.Show("Is null");
}
Run Code Online (Sandbox Code Playgroud)
谢谢你的建议!
所以我有一个xml,它具有与此类似的结构:
<MyObject>
<PropertyA>Value</PropertyA>
<PropertyB>Value</PropertyB>
<PropertyC>Value</PropertyC>
<ArrayOfOtherObject>
<OtherObject>
<PropertyX>Value</PropertyX>
<PropertyY>Value</PropertyY>
<PropertyZ>Value</PropertyZ>
</OtherObject>
<OtherObject>
<PropertyX>Value</PropertyX>
<PropertyY>Value</PropertyY>
<PropertyZ>Value</PropertyZ>
</OtherObject>
<OtherObject>
<PropertyX>Value</PropertyX>
<PropertyY>Value</PropertyY>
<PropertyZ>Value</PropertyZ>
</OtherObject>
</ArrayOfOtherObject>
</MyObject>
Run Code Online (Sandbox Code Playgroud)
有没有办法可以反序列化MyObject而不是ArrayOfOtherObject?然后在需要时做一个懒惰的ArrayOfOtherObject加载?
我通常使用XmlDeserialization,但AFAIK总是加载整个东西.
谢谢!
无论如何,类可以捕获应用程序中的最后一次单击吗?就像是
public class MyClickManagerClass
{
public MyClickManagerClass()
{
// subscribe to a global click event
}
private void GlobalClickEventHandler(object sender, EventArgs e)
{
// do something with the click here
}
}
Run Code Online (Sandbox Code Playgroud)
谢谢你的时间!
我正在试图绑定到RadioButton.IsChecked属性,它只能工作一次.在那之后,绑定不起作用,我不知道为什么会发生这种情况.任何人都可以帮忙吗?谢谢!
这是我的代码.
C#
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
this.DataContext = new ViewModel();
}
}
public class ViewModel
{
private bool _isChecked1 = true;
public bool IsChecked1
{
get { return _isChecked1; }
set
{
if (_isChecked1 != value)
{
_isChecked1 = value;
}
}
}
private bool _isChecked2;
public bool IsChecked2
{
get { return _isChecked2; }
set
{
if (_isChecked2 != value)
{
_isChecked2 = value;
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
XAML:
<Grid>
<StackPanel> …Run Code Online (Sandbox Code Playgroud) 有没有办法让控件只使用Dark或Light主题?我正在开发一个大多数黑暗的应用程序,我们有一些黑暗的自定义背景.处理所有文本块,这些文本块始终是白色的.但按钮,文本框,复选框,radiobuttons.当手机的主题设置为浅色时,所有这些都会变黑,而且几乎看不到它们.
这个问题是我发现自己要混合来处理每个控件在每个状态上看起来的方式.EG,在Light主题中,按钮文本变为黑色,仅在按下时为白色.有没有办法让按钮只使用黑暗主题?无视手机的实际主题设置是什么?
谢谢.
这真的很奇怪。在 Blend 4 中,当我在设计器中看到应用程序时,自定义字体可以工作,但是当我运行它时,字体消失了,它又回到了 arial 或其他东西。这是我的 XAML:
<TextBlock Text="Text G" FontFamily="/ProjectName;component/Fonts/#Futura Lt BT" FontSize="48" Background="#FFC44747" />
Run Code Online (Sandbox Code Playgroud)
字体位于名为“Fonts”的文件夹中,我尝试使用该字体的控件位于名为“Controls”的文件夹中。我知道“Fonts”文件夹与“Controls”文件夹的相对位置一定有问题,但我已经尝试了很多东西,但它不起作用。
此外,我在此处放置的 XAML 标记是 Blend 在我选择自定义字体时创建的内容。字体被复制为资源好吧(我已经检查了 csprof 文件,它就在那里)。
有任何想法吗?这已经踢了我几个小时了。
谢谢。
如果我执行以下操作:
public class Test
{
public static void Main()
{
List<Person> persons = new List<Person> { new Person() };
persons[0].Sneezing += new EventHandler(Person_Sneezing);
persons = null;
}
public static void Person_Sneezing(object sender, EventArgs e)
{
(sender as Person).CoverFace();
}
}
Run Code Online (Sandbox Code Playgroud)
亲自[0]的人是否仍然存在于内存中,因为它的打喷嚏代理具有对Person_Sneezing方法的引用或者它是否被GC收集?
关于Client Profile安装的最后一个问题.我下载了Microsoft .NET Framework Client Profile Online Installer,因为我们想将它放在安装CD中,因为我们的最终用户可能没有.net framework 3.5或Internet.所以我们希望能够处理这两种情况.
在先决条件中,我能够选择文件的位置,但我不知道它应该在哪里.我希望能够以某种方式放置CD的路径,例如d:\ ProductName\Prerequisites\DotNetFx35ClientSetup.exe,以便它可以获取它并从那里安装它.有没有人知道如何实现这一目标?
谢谢.
这是先决条件窗口:

我有这段XAML代码:
<Window x:Class="SizingTest.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<Grid>
<Label x:Name="theLabel" Width="Auto">A very large label with a lot of text</Label>
</Grid>
</Window>
Run Code Online (Sandbox Code Playgroud)
我想,在后面的代码中,我试图获得标签的实际宽度
theLabel.ActualWidth
Run Code Online (Sandbox Code Playgroud)
会做的伎俩,但尝试此代码后:
public Window1()
{
InitializeComponent();
double width = theLabel.ActualWidth;
}
Run Code Online (Sandbox Code Playgroud)
width的值为0,我还检查了Label.Width,它返回NaN,theLabel.DesiredSize.Width,它也返回0.我可以用什么来查找标签的实际宽度?
谢谢.
wpf ×4
c# ×3
.net ×1
arrays ×1
binding ×1
click ×1
fonts ×1
installation ×1
memory-leaks ×1
php ×1
size ×1
window ×1
wpf-controls ×1