---
title: "WPF set width of control by binding in centimeter"  
description: "WPF set width of control by binding in centimeter"  
author: "Takeshi Okada"  
published: 2013-09-23  
updated: 2013-09-23  
canonical: https://www.mindstick.com/forum/1496/wpf-set-width-of-control-by-binding-in-centimeter  
category: "wpf"  
tags: ["wpf"]  
reading_time: 1 minute  

---

# WPF set width of control by binding in centimeter

I want to set the width of my [control](https://www.mindstick.com/blog/197/asp-dot-net-repeater-control) by [binding](https://www.mindstick.com/blog/146/dynamic-binding-in-c-sharp) and in centimeters. (it's for the [size](https://www.mindstick.com/forum/159799/how-can-you-manage-the-size-of-mdf-and-ldf-files) of my printout so I find it easy to work with centimeters)

So I want to do something like this:

<FlowDocument x:[Name](https://yourviews.mindstick.com/view/87450/how-to-generate-a-brand-name-using-linkedin-comprehensive-guide)="flowdocument" PageWidth="{Binding Barcode.Width}" PageHeight="{Binding BarcodeSjabloon.Height}">

but I want to set it in centimeters like this:

<FlowDocument x:Name="flowdocument" PageWidth="20cm" PageHeight="30cm">

Any idea how to achieve this?

## Replies

### Reply by Pravesh Singh

Hi Takeshi,

You can define a converter that understands your syntax and uses the current DPI setting to convert to an appropriate number of pixels.


---

Original Source: https://www.mindstick.com/forum/1496/wpf-set-width-of-control-by-binding-in-centimeter

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
