2015-07-03 2 views
0

Я хотел бы определить значение DesignWidth с константой, но вид, по-видимому, не имеет определенной ширины в Blend. У меня есть Constants.classОпределить конструкциюWidth с константой в файле XAML

public static class Constants 
{ 
    public static int ApplicationWidth { get { return 1280;} } 
    public static int ApplicationHeight { get { return 720; } } 
} 

и View.xaml

<UserControl 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:constants="clr-namespace:app.Constants" 
    d:DesignWidth="{x:Static constants:Constants.ApplicationWidth}"> 
</UserControl> 

В Visual Studio The View Ширина 267px и в купаж 262px. Как установить Width без жесткого кодирования значений в файлах XAML, чтобы иметь желаемый размер в Blend Visual Studio?

+0

Возможно, класс 'Contants' должен быть статическим? Просто мысль. –

+0

Я получаю тот же результат со статическим классом – Ionut

ответ

1
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:constants="clr-namespace:app.Constants" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    mc:Ignorable="d" 
    d:DesignWidth="{Binding Source={x:Static constants:Constants.ApplicationWidth}}"> 
+0

Спасибо, он работает – Ionut

Смежные вопросы