Wednesday, 28 March 2012

Adding Calculated Columns to WPF DataGrids

image

 

I’m still fairly new to DataBinding in WPF/XAML, and still in awe to degree of learning required to accomplish simple tasks such as Adding a calculated column to a DataGrid.

 

The most basic of solutions I found required a gross exaggeration of work that I’m not willing to undertake, especially for the simplicity of the task at hand.

 

So, in order to avoid having to write a unpleasant number of classes just to multiply one DataBound column with another, I’ve decided to make my DataContext a DataTable in a DataSet. With that, I’ve added a virtual column in the DataTable’s definition, and rather then defining a “Source” I alternatively defined an expression, which in turn is my intended calculation.

 

Column Expression’s are very flexible, so please review Microsoft’s Reference to see what it can do for you.

Advantages:

  1. No need to define attributes of the data within XAML, or resort to binding to static resources which you have to code.
  2. DataTables are easy to code, or if your as lazy as me, accessible through the DataSet Designer in Visual Studio. (The designer additionally gives you facility to test your expression by right clicking the table and selecting “Preview Data…”)
  3. Your XAML doesn’t need to bind to one column differently to than the others… In turn, allowing for AutoGenerateColumns as an available option.

Some XAML example

<DataGrid
    AutoGenerateColumns="False"
    ItemsSource="{Binding}"
    Name="DataGrid1">
    <DataGrid.Columns>
        <DataGridTextColumn 
            Header="Name"
            Binding="{Binding Path=Tenant_Name}" />
        <DataGridTextColumn 
            Header="Sq Feet&#x0d;&#x0a;"
            Binding="{Binding Path=Tenant_SqFeet}" />                
        <DataGridTextColumn 
            Header="Basic Rent&#x0d;&#x0a;"
            Binding="{Binding Path=Tenant_BaseRent}" />
        <DataGridTextColumn 
            Header="&#x0d;&#x0a;x Sq Feet"
            Binding="{Binding Path=Tenant_Calc_SqFeetByBaseRent}" />                
    </DataGrid.Columns>            
</DataGrid>

 

Now,

My only concern with this solution is that it’s too graceful not to be posted elsewhere. So if anyone can explain to me why this is not the ideal method for displaying a calculated column, please let me know in the comments.

 

Sincerely,

Sunday, 4 March 2012

Regulating Robocalls

 

Here’s an idea: Let’s improve privacy and protect democracy at the same time!

 

Courtesy: CBC

 

The “Robocalls” scandal brings another “Technology” related issue up to the forefront of the political arena, and while everyone focuses on the “Who done it?” we forget to focus on the core concern, “how do we regulate it?”

 

Let’s take a step back for a second, and look at what IS actually happening here. A robocall itself is an automated call where a list of numbers is attended to by either a recording, or by an operator “doing their job” which involves reading a script given to them.

 

With the facility for telephony technologies to process listings with ease and affordably, we (the public) have been getting harassed by various services such as:

  1. Air Duct Cleaning services.
  2. New Windows or Doors for your house.
  3. Got $10,000+ of credit card debt? Let us help you.
  4. Mortgage Consultants who can cut mortgage in half
  5. Home alarm services
  6. You won a Free Vacation for the most exotic locations in the world.

    That last one is interesting, because once the operator insinuated we were racist for not accepting a free cruise to Mexico.

Here is the worrisome part of the above list, each of the above mentioned robocall’s are answered in our home at least once a month  regardless of being on the national “Do Not Call” list since inception, as well we have consistently notified each caller of being on such list.

 

The National Do Not Call List in my opinion does not work – it is a failed mechanism implemented by the CRTC which fails at penalizing or policing existing robocalls sufficiently.

 

I further want to outline that providing the police with more capacity over policing such activity would be ill-advised, as is our current legal framework already allows police forces of every jurisdiction to tap phone calls without a warrant or obtain all your telecommunication data under investigation  and if we allow C-30 to pass, combined with certain technologies, we will literally give police unlimited access to everything we do with our cell phone (not just your internet usage)

 

We need to start focusing on legitimate privacy - I’m talking allowing our phone services to have the same privacy that our ISP currently provides us in regards to our IP address – I’m talking sans-Bill C-30 privacy here.

 

We should consider legislation for the following:

  1. Phone numbers should be easily changed without charge
  2. All phone listings should be opt-in only.
  3. Phone listing should be distinguished by use – marketing, surveys, personal, business, ect.
  4. Basic phone services such as call-display, ident-a-call, private call restriction and call source tracking should be available without charge (it costs the phone company literally nothing to enable or facilitate these services).
  5. Surveys (or other forms of robocalls) should be authorized by an authority.
  6. Having an un-authorized phone listing should be against the law.
  7. Telecommunication providers should not be able to obtain your call data to any extent without being authorized (this too can be considered a type of phone listing)
    And yes, this does happen. Even the content of your text messages:
    1. http://gizmodo.com/5863849/your-android-phone-is-secretly-recording-everything-you-do
    2. http://gizmodo.com/5793925/your-iphone-is-secretly-tracking-everywhere-youve-been
  8. Call centers should be responsible/liable for callings regardless of whatever indemnity they may have on contract.
  9. Call centers must disclose who they are calling on behalf of at the beginning of any mass call service, as well offer opportunity for the call recipient to choose not to accept the call.
  10. And call centers must disclose details of their phone calls upon request by the authorities (Let’s take the privacy of those who are assaulting the citizens away, not the citizen’s for a change)

So, when elections Canada gives a politician a phone list with a stern warning not to abuse it and dispose it after the election. The politician would not be tempted to fail at disposing such list or distribute such list to a call center. Nor will a call center be too excited to have a list of phone numbers that is not authorized or facilitating fraud due to having no legal protection in terms of responsibility over the content of the calls themselves.

 

Therefore if our government were to implement an anti-Bill-C30 type bill,

it is possible…

and i might be going out of a limb by suggesting this..

 

protect democracy!

 

And privacy!

 

AT THE SAME TIME!!~!!

 

Seriously,

Twitter

Page Hits