Tag: xaml

将SortedList或Dictionary 添加到ResourceDictionary

有没有办法将SortedList或Dictionary添加到ResourceDictionary并通过XAML使用(并绑定!)它到控件? 我试过这个,但我无法弄清楚如何做到这一点: ***

将可观察集合绑定到XAML中的ListBox

我花了很多时间来解决这个问题。 我有一个数据类: public class User : INotifyPropertyChanged { private int _key; private string _fullName; private string _nick; public int Key { get{return _key;} set { _key = value; NotifyPropertyChanged(“Key”); } } public string Nick { get { return _nick; } set { _nick = value; NotifyPropertyChanged(“Nick”); } } public string FullName { get { return […]

如何在Xaml文件中的Xamarin.Forms中添加Checkbox?

我是xamarin.forms的新手,我需要添加一个复选框,单选按钮和下拉列表。 我从网上尝试了一些样本,但我无法获得复选框。 任何人都可以帮助我在xamarin.forms中实现这一目标吗? Xaml文件 要么 一些链接或示例代码将使其更容易理解。

WPF TextBox MaxLength – 有没有办法将它绑定到绑定字段上的数据validation最大长度?

视图模型: public class MyViewModel { [Required, StringLength(50)] public String SomeProperty { … } } XAML: 有没有办法避免设置TextBox的MaxLength以匹配我的ViewModel(由于它在不同的程序集中可能会改变)并让它根据StringLength要求自动设置最大长度?

使用MVVM框架内的Button动态添加TextBox

我一直爬上陡峭的WPF山! 所以我想创建一个允许用户动态添加文本框的UI。 要做到这一点,他们会点击一个按钮。 我已经设法使用后面的代码创建它,但我想转向MVVM结构,所以我在视图中没有任何代码。 我已经尝试过ICommand和ObservableCollection,但我遗漏了一些东西而且我不知道在哪里。 这是我的简单例子。 XAML:非常基本,只有一个按钮可以添加一行。 C#代码背后 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; namespace WPFpractice072514 { /// /// Interaction logic for MainWindow.xaml /// public partial class MainWindow : Window { #region members […]

如何在XAML中使用枚举类型?

我正在学习WPF,我遇到了以下问题: 我在另一个命名空间中的枚举类型比我的XAML: public enum NodeType { Type_SYSTEM = 1, // System Type_DB = 2, // Database Type_ROOT = 512, // Root folder Type_FOLDER = 1024, // Folder } 在我的XAML中,我想用整数触发图像 有没有办法在XAML代码中直接获取整数值并将其与枚举类型进行比较? 我的枚举是在名称空间AnotherNamespace.Types

在WPF控件可见性更改上应用动画

我的xaml是 Down some controls here in a horizontal strip , by default its hidden and when some one click on top button its visible and it wil be hidden when some one click outside this area 按钮鼠标的代码是 private void showTopMenu_MouseEnter(object sender, MouseEventArgs e) { TopMenuArea.Visibility = Visibility.Visible; } 如何在更改TopMenuArea的可见性时应用动画效果? 有没有办法直接从xaml做到这一点?

如何在WPF中为Margin属性设置动画

我想移动矩形对象的动画以在x轴上移动它。 我是WPF动画的新手,从以下开始: 显然我发现我不能使用Margin.Left作为Storyboard.TargetProperty或在Value属性中使用134,70,0,0 。 那么,如何在XAML WPF中移动对象。

如何根据用户角色操作WPF GUI

我使用.NET的IIdentity和IPrincipal对象来实现基于角色的安全性,我正在修改基于当前用户所拥有的角色显示的控件。 我的问题是推荐的方法是在WPF窗口中启用/禁用字段 – 显示/隐藏依赖于IIdentity.IsInRole类型调用的字段。 这可以在XAML中完成,还是我必须将其抽象为代码,我认为后面的代码有点混乱; this.txtUserName.IsReadOnly = !MyPrincipal.CurrentPrincipal.IsInRole(“Administrator”); this.mnuCreateUser.Visibility = MyPrincipal.CurrentPrincipal.IsInRole(“Administrator”); ? Visibility.Hidden : Visibility.Visible; (注意;我的代码在执行函数时检查角色,我要做的是根据角色修改GUI,因此用户看不到/看到他们无权访问的只读元素)

WPF数据绑定:如何使用XAML将枚举数据绑定到combobox?

我上课了: public class AccountDetail { public DetailScope Scope { get { return scope; } set { scope = value; } } public string Value { get { return this.value; } set { this.value = value; } } private DetailScope scope; private string value; public AccountDetail(DetailScope scope, string value) { this.scope = scope; this.value = value; […]