Is there a way to use the existing WPF BooleanToVisibilityConverter converter but have False values convert to Hidden instead of the default Collapsed, or should I just write my own? I'm on a project where it's tremendous overhead to do something simple like this (shared stuff goes into a separate solution, and the rebuild/checkin/merge process is an overgrown mutated behemoth of a process), so I'd prefer if I could just pass a parameter to the existing one than to jump through the hoops just mentioned.
相关问题
- Generic Generics in Managed C++
- VNC control for WPF application
- How to Debug/Register a Permanent WMI Event Which
- 'System.Threading.ThreadAbortException' in
- Bulk update SQL Server C#
相关文章
- .net中MessageBox.Show使用问题
- IdentityServer 报错:"idp claim is missing"
- 在 IdentityServer 中如何给 id token 添加更多信息
- WPF:如何在Trigger里修改Orientation?
- IdentityServer 的 Selector 在哪个 nuget 包
- 使用 IdentityServer 的项目遭遇错误:"IDX20803: Unable to obt
- ASP.NET Core ConfigureServices 中从 appsettings.json
- WPF aforge 怎么做一个 圆形的播放器
Can you not just use a style instead of a converter? The code would be something like:
You'll need to provide the property binding yourself to point to your bool property.
I like to use the parameter for reversing the visibility logic: To reverse logic simply put: ConverterParameter=Reverse in your xaml code
I wrote BoolToVisibilityConverte where you can pass invisible state in Parameter:
So you can bind like this:
Hope this helps :)
I've found the simplest and best solution to be this:
When using it, just configure a version that does exactly what you need it to in XAML like this:
Then use it in one or more bindings like this:
This simple solution addresses hidden/collapsed preferences as well as reversing/negating the effect.
SILVERLIGHT USERS must drop the
[ValueConversion]
declaration as that attribute is not part of the Silverlight framework. It's not strictly needed in WPF either, but is consistent with built-in converters.Unfortunately, it only converts to Visible or Collapsed, so you'll have to write your own. Here is the Convert method according to Reflector: