c#wpf多重绑定不是很流行(c# wpf Multibindings not aviable)
我想要做的事很简单。 我有一个窗口,我希望标题绑定到两个不同的属性。 标题应在每次更改属性时进行更新。
我第一次尝试并且没有工作
<Window x:Class="Giag.DataReader.ControlLibrary.Windows.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="{Binding Path=Clientname} {Binding Path=LoadedConfiguration}"
那么我在这里和这里阅读关于多重绑定。 并尝试像这样使用它实际上也不起作用
<Window x:Class="Giag.DataReader.ControlLibrary.Windows.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <Window.Title> <Multibinding StringFormat="{}{0} + {1}"> <Binding Path="Clientname" /> <Binding Path="LoadedConfiguration" /> </Multibinding> </Window.Title>
错误是多重绑定不支持WPF项目中 ,我认为没有任何意义。
所以,即时猜测是缺少xmlns或缺少.dll。 我发现Multibindings在“PresentationFramework.dll”里面,我引用了它。 根据msdn,你需要http://schemas.microsoft.com/winfx/2006/xaml/presentation或http://schemas.microsoft.com/netfx/2007/xaml/presentation包括,我做了。
在这里,我可能实际上没有更进一步,我希望你能得到。
what i want to do is quite simple. I have got a Window and I Want the Title to be bound to two different Properties. The Title should be Updated everytime one of the Properties changes.
What I tried first and didnt work
<Window x:Class="MyNamespace.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="{Binding Path=Clientname} {Binding Path=LoadedConfiguration}"
So then I read here and here about Multibindings. And tried its usage like this what actually doesnt work, too
<Window x:Class="MyNamespace.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <Window.Title> <Multibinding StringFormat="{}{0} + {1}"> <Binding Path="Clientname" /> <Binding Path="LoadedConfiguration" /> </Multibinding> </Window.Title>
The Error ist that Multibinding is not supported in a WPF project, what in my opinion doesnt make any sense.
So, what im guessing is a missing xmlns or a missing .dll. I found out that Multibindings are inside "PresentationFramework.dll", which i have referenced. According to msdn, you need either http://schemas.microsoft.com/winfx/2006/xaml/presentation or http://schemas.microsoft.com/netfx/2007/xaml/presentation to include, which I did.
Here I may actually not get any further, I hope you get.
原文:https://stackoverflow.com/questions/28743044
最满意答案
使用
MultiBinding
,而不是Multibinding
。 XAML是区分大小写的。Use
MultiBinding
, notMultibinding
. XAML is case sensitive.
相关问答
更多-
这个答案可能有你想要的: 我认为你真正想做的是订阅Startup事件。 您可以在XAML文件中执行此操作 单击此处开始使用WPF This answer might have what you're looking for: I think what you really want to do is to subscribe to the Startup event. You can do this in your XAML file Click here to get started with WPF
-
c#wpf多重绑定不是很流行(c# wpf Multibindings not aviable)[2022-12-04]
使用MultiBinding ,而不是Multibinding 。 XAML是区分大小写的。 Use MultiBinding, not Multibinding. XAML is case sensitive. -
VB WPF到C#WPF(VB WPF to C# WPF)[2022-09-30]
请在线查看答案。 主要问题是转换器已将所有类型推断调用( Dim variable = ... )转换为动态,这是不正确的。 你应该使用var来进行类型推断。 private void Aberdeen() { if (TXTCounty.Text == "Aberdeen") { Microsoft.Maps.MapControl.WPF.Location[] CountyLocation = new Microsoft.Maps.MapControl.WPF.Location[ ... -
在C#WPF中发出嘟嘟声(Making A Beep in C# WPF)[2022-05-03]
您可以使用以下方式发出“嘟嘟”声: SystemSounds.Beep.Play(); You can make a "beep" sound using: SystemSounds.Beep.Play(); -
ListView C#WPF绑定(ListView C# WPF Binding)[2022-08-16]
这与绑定无关,但是您的第一个问题是每次添加List,只有一个项目作为项目。 而是创建一个列表,将项添加到该列表,然后使用该列表设置ItemsSource 。 var items = new List (); foreach (DataRow dr in dt.Rows) { items.Add(new UserScenarist() { idScenarist = Int32.Parse(dr["id ... -
C#WPF绑定行为(C# WPF Binding Behavior)[2022-11-23]
您有两个myConfigurationViewModel实例。 一个是在XAML中创建的,第二个是在表单的代码隐藏中创建的。 您正在调用后面代码中的LoadConfiguration,它永远不会被设置为窗体的DataContext。 从XAML中删除它: -
绑定宽度c#wpf(Binding width c# wpf)[2022-03-13]
Binding mybinding = new Binding(); mybinding.Path.Path = "ActualWidth"; mybinding.ElementName = "img" Mytarget.SetBinding(MYTARGET.WidthProperty, mybinding); MYTARGET是类, Mytarget是对象名。 Binding mybinding = new Binding(); mybinding.Path.Path = "ActualWidth"; ... -
WPF MultiBindings(WPF MultiBindings)[2022-02-03]
为什么不使用XAML? 以下代码应该工作: MultiBinding multiBinding = new MultiBinding(); multiBinding.Converter = converter; multiBinding.Bindings.Add(new Binding { ElementName = "FirstSlider", Path = new PropertyPath("Value") }); multiBinding.Bindings.Add(new Bind ... -
另一种转换方法是使用MultiValueConverter。 这不需要依赖属性或其他NotifyPropertyChanged。 关于MultiValueConverter的重要一点是,您按照将它们放入XAML的顺序获取“值”。 转换器变为: public class NumberToSpecialStringConverter : IMultiValueConverter { public Convert(...) { //This is going to the UI, f ...
-
C#WPF加密(C# WPF Encryption)[2022-01-18]
不要尝试创建自己的加密算法,而应使用.NET Framework中通过System.Security.Cryptography提供的加密类。 对于密码,一个好的解决方案是使用单向加密,如MD5哈希或SHA1 。 当用户输入他/她的密码时,您计算散列并将其与存储的散列进行比较。 这样做的好处是您无需担心如何安全地存储用于加密密码的密钥。 为了增加使用单向哈希的安全性,你可以应用一个盐,这有助于限制某些类型的攻击的有效性,如字典攻击等。我还没有阅读wiki条目,但我相信这将提供更多细节。 Do not try ...