如何将这个按钮添加到WPF中的标题栏,因为它被用在许多应用程序中,我认为它将被内置或者其他东西,但看起来并非如此.无论如何,如果您对此有任何了解,请告诉我.
谢谢.
编辑:
是不是有什么等同于这个?
基本上,要有?赢取表格中的图标,您需要做的就是:
public Form1()
{
InitializeComponent();
this.HelpButton = true;
this.MaximizeBox = false;
this.MinimizeBox = false;
}
Run Code Online (Sandbox Code Playgroud)
WPF有没有这样的东西?
我只是想找到一种方法来控制TreeView节点通过它们绑定的对象的扩展/折叠.该对象具有一个IsExpanded属性,我想使用它来显示TreeView基于该属性展开或折叠的节点本身.
这是我的代码:
C#:
public partial class Window2 : Window
{
public Window2()
{
InitializeComponent();
this.DataContext = new List<Parent>() { Base.GetParent("Parent 1"), Base.GetParent("Parent 2") };
}
}
public class Base
{
public string Name { get; set; }
public bool IsExpanded { get; set; }
public static Parent GetParent(string name)
{
Parent p = new Parent() { Name = name };
p.Children.Add(new Child() { Name = "Child 1", GrandChildren = new ObservableCollection<GrandChild>() { new GrandChild() …Run Code Online (Sandbox Code Playgroud) 我在数据库表中有一个Time列.日期并不重要,我们只想要一天的时间.哪种类型最适合用C#表示?我打算使用DateTime,但我不喜欢约会的想法.
我正在试图弄清楚这个虚拟化功能,我不确定我是否理解它错误或发生了什么,但我正在使用ANTS内存分析器来检查虚拟化TreeView中的项目数量,以及它只是不断增加.我有一个包含1,001个项目的TreeView(1个根,1000个子项),我总是得到1,001个TreeViewItems,1,001个ToggleButtons和1,001个TextBlocks.是不是虚拟化应该重复使用这些项目?如果是这样,为什么我每个都有1,001个呢?此外,CleanUpVirtualizedItem永远不会触发.
如果我理解这个错误并且你有资源如何使用它,请告诉我.我通过互联网搜索但没有找到任何有用的东西.
编辑:
甚至树所使用的内存也都来自aporx.当我展开并滚动浏览所有项目时,4mb到12mb.
让我知道谢谢.
这是我的代码.
XAML:
<Window x:Class="RadTreeViewExpandedProblem.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>
<TreeView x:Name="treeView"
VirtualizingStackPanel.IsVirtualizing="True"
VirtualizingStackPanel.CleanUpVirtualizedItem="TreeView_CleanUpVirtualizedItem">
<TreeView.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel />
</ItemsPanelTemplate>
</TreeView.ItemsPanel>
</TreeView>
</Grid>
</Window>
Run Code Online (Sandbox Code Playgroud)
C#:
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
TreeViewItem rootItem = new TreeViewItem() { Header = "Item Level 0" };
for (int i = 0; i < 1000; i++)
{
TreeViewItem itemLevel1 = new TreeViewItem() { Header = "Item Level 1" };
itemLevel1.Items.Add(new TreeViewItem());
rootItem.Items.Add(itemLevel1);
}
treeView.Items.Add(rootItem);
} …Run Code Online (Sandbox Code Playgroud) 好吧问题是我有这个枚举,但我不希望组合框显示枚举的值.这是枚举:
public enum Mode
{
[Description("Display active only")]
Active,
[Description("Display selected only")]
Selected,
[Description("Display active and selected")]
ActiveAndSelected
}
Run Code Online (Sandbox Code Playgroud)
因此,在ComboBox中,而不是显示Active,Selected或ActiveAndSelected,我想为枚举的每个值显示DescriptionProperty.我有一个名为GetDescription()的扩展方法用于枚举:
public static string GetDescription(this Enum enumObj)
{
FieldInfo fieldInfo =
enumObj.GetType().GetField(enumObj.ToString());
object[] attribArray = fieldInfo.GetCustomAttributes(false);
if (attribArray.Length == 0)
{
return enumObj.ToString();
}
else
{
DescriptionAttribute attrib =
attribArray[0] as DescriptionAttribute;
return attrib.Description;
}
}
Run Code Online (Sandbox Code Playgroud)
那么有没有办法可以将枚举绑定到ComboBox并使用GetDescription扩展方法显示它的内容?
谢谢!
我有一个不能继承DependencyObject的对象或者使用NotifyPropertyChanged,我把它绑定到了很多控件,所以当属性改变时,我不想去每个控件并改变它在代码上的值,所以我认为必须有一种方法可以告诉XAML"重新绑定"所有与一两行代码绑定的内容,而不是去:
label1.Content = myObject.DontNotifyThis;
label2.Content = myObject.DontNotifyThisEither;
label3.Content = myObject.DontEvenThinkOfNotifyingThis;
label4.Content = myObject.NotSoFastPal;
Run Code Online (Sandbox Code Playgroud)
等等......等等......
这是一个过于简单的例子:
XAML:
<Window x:Class="StackOverflowTests.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" x:Name="window1" Height="300" Width="300" Loaded="window1_Loaded">
<Grid x:Name="gridMain">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Label Grid.Row="0" Content="{Binding Status}" ContentStringFormat="Today's weather: {0}" />
<Label Grid.Row="2" Content="{Binding Temperature}" ContentStringFormat="Today's temperature: {0}" />
<Label Grid.Row="1" Content="{Binding Humidity}" ContentStringFormat="Today's humidity: {0}" />
</Grid>
</Window>
Run Code Online (Sandbox Code Playgroud)
C#:
using System.Windows;
namespace StackOverflowTests
{
/// <summary>
/// Interaction logic for Window1.xaml
/// </summary>
public …Run Code Online (Sandbox Code Playgroud) 我可以在发布模式下使用Trace.WriteLine吗?
Trace.Write和Debug.Write之间的主要区别是什么?
我们试图提出一种虚拟化的好方法TreeView,数据并不是真正的问题,因为它非常轻(每个项目大约16个字节),问题是我们可能有数万个,尽管实际上数据只需要160 kb的内存,treeview项目确实使用了更多的内存.我们现在尝试使用3种不同的树进行虚拟化,WPF,Infragistics和Telerik.所有这些都有很大的问题,使它们无法用于我们的应用程序:
WPFTreeView:滚动条显示了一些怪异的行为,周围很多跳跃,变化大小不一致,用鼠标拖动它不能正常工作,滚动(跳来回)
Telerik:项目消失,滚动条也不稳定,项目随机展开崩溃,样式不起作用
Infragistics:项目根本没有虚拟化,每个项目都留在内存中,使虚拟化无用.
我们几个月来一直在努力解决这个问题,但我们还没有找到一个好的解决方案.有没有人成功实现TreeView了超过9000项的虚拟化?如果是这样,你的策略是什么?你使用了第三方控件吗?它100%有效吗?
任何建议都非常感谢.
谢谢.
所以我有这个UserControl在另一个UserControl里面.让我们称他们为ParentUC和ChildUC.我需要从ChildUC获得ParentUC.
我知道要获得窗口所有者Window.GetWindow(userControl),但UserControl没有像这样的AFAIK方法.
谢谢您的帮助!
我有这门课:
public class MySerializableClass
{
public List<MyObject> MyList { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
如果MySerializableClass被序列化时MyList为null,那么当它反序列化时我需要将它置为null,但是当它反序列化我的类时,XmlSerializer总是初始化它.
有没有办法避免它初始化null属性?
当它为空时,MyList甚至不会记录在序列化文件中.当我使用空值加载它并再次保存时,MyList不再为null,它被序列化为包含0项的List <>,但不是null.
谢谢.
更多信息:
由于类的结构中存在一些代码限制,IsDeserializing属性不可行