C# WPF通过装订设置控件的宽度,单位为厘米

C# WPF通过装订设置控件的宽度,单位为厘米,c#,wpf,binding,C#,Wpf,Binding,我想通过绑定和以厘米为单位设置控件的宽度。(这是我打印输出的尺寸,因此我发现使用厘米很容易) 所以我想这样做: <FlowDocument x:Name="flowdocument" PageWidth="{Binding Barcode.Width}" PageHeight="{Binding BarcodeSjabloon.Height}"> <FlowDocument x:Name="flowdocument" PageWidth="20cm" PageHeight

我想通过绑定和以厘米为单位设置控件的宽度。(这是我打印输出的尺寸,因此我发现使用厘米很容易)

所以我想这样做:

 <FlowDocument x:Name="flowdocument" PageWidth="{Binding Barcode.Width}" PageHeight="{Binding BarcodeSjabloon.Height}">
 <FlowDocument x:Name="flowdocument" PageWidth="20cm" PageHeight="30cm">

但我想把它设置为厘米,如下所示:

 <FlowDocument x:Name="flowdocument" PageWidth="{Binding Barcode.Width}" PageHeight="{Binding BarcodeSjabloon.Height}">
 <FlowDocument x:Name="flowdocument" PageWidth="20cm" PageHeight="30cm">


您知道如何实现这一点吗?

您可以定义一个转换器,该转换器可以理解您的语法并使用转换为适当数量的像素