Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 928743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T20:03:39+00:00 2026-05-15T20:03:39+00:00

In WPF it’s better to create a property complex (i.e. of type Visibility) or

  • 0

In WPF it’s better to create a property “complex” (i.e. of type “Visibility”) or a property simple (i.e. of type boolean) and then using a converter to bind the property? The first way is shorter to write, but I don’t know what is better about the performances.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T20:03:40+00:00Added an answer on May 15, 2026 at 8:03 pm

    The performance hit of using a converter is going to be negligible. What you should base the choice on, though, is where you’re implementing the property.

    A Visibility property only makes sense on a class in the UI layer (a custom control or maybe a viewmodel). If you’re creating a property on a model class that just happens to drive your UI in this instance, it would make more sense to use a boolean and a converter.

    EDIT: added (slightly contrived) example

    For example, imagine you have a data class (a model) for an editable object called Foo, and a Foo can be “simple” or “advanced.” An “advanced” Foo will display extra editing controls in the UI – so we need to bind the Visibility property of the advanced edit panel to some property.

    Your Foo class could have a property to indicate whether it’s advanced or not. That property should definitely be a boolean – NOT a Visibility – because your Foo class shouldn’t care about any specifics of the UI that’s displaying it. So a boolean Foo.IsAdvanced would be a suitable property.

    In this case, you could bind directly to Foo.IsAdvanced and use a converter. What you definitely don’t want to do is create a Visibility property Foo.AdvancedEditControlVisibility, because Foo is supposed to be back-end data class.

    If you wanted to create a property that doesn’t require a converter, you should create that property in a higher class, one specific to your UI. Some architectural patterns would call this a “ViewModel” class – it’s a class that presents the model in a way that the data is more suitable for display by the UI. So, you might create a class that takes a Foo and exposes an AdvancedEditControlVisibility property that is based on the value of its Foo.IsAdvanced.

    In this case, you could bind directly to the property on the viewmodel with no converter. Note that ultimately you’ve done the conversion anyway – you’ve just made it a more explicit part of your code, instead of being confined to markup.

    The thought process here is that the viewmodel is a “higher level” class – one that wraps your data class and includes UI-specific logic – and so it’s more appropriate to include code that is specific to your UI. Ideally, you should take each class of your project in turn and make sure that it has a specific purpose: if Foo is a business-object that holds data, why should it expose (or even care about!) the visibility of some piece of UI used to display it? What would happen if you put a Foo in a commandline app, or a web application? If you have WPF-UI-specific logic in a business class then your encapsulation is wrong – but separation of concerns in this manner is one of the hardest things to get right sometimes.

    And performance-wise you’ll notice little difference. 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

WPF's Window.ShowDialog method returns a nullable boolean. So does CommonDialog.ShowDialog . Now, I understand
WPF, Browserlike app. I got one page containing a ListView. After calling a PageFunction
WPF's view model oriented way of doing things makes it very tempting to just
WPF doesn't provide the ability to have a window that allows resize but doesn't
WPF GridSplitter makes my Grid wider than my Window! I've got a WPF Grid
WPF validation system performs intial validatation of an object (I mean - all fields
WPF document viewing controls that support annotations include FlowDocumentReader and FlowDocumentScrollViewer, as well as
WPF is positioned as a successor to WinForms, but given Microsoft's practice of abandoning
WPF allows a control library to provide different resource dictionaries for different system themes,
WPF's ItemsControl will display a focus rectangle when it thinks it has focus and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.