Viewbox 内の Canvas をいじっていますが、残念ながら、Canvas 内の要素を表示する唯一の方法は、Height と Width を割り当てる必要があります。ただし、問題は、Height と Width の値がデータバインディングを介して ViewModel から取得されることです。
d:
Blend は、 に設定されているデザイナーの名前空間でこれを回避することを知っていますxmlns:d="http://schemas.microsoft.com/expression/blend/2008"
。VS2008 で同様のものを使用して、デザイナーでこれらの値を指定し、作業内容を確認できるようにしたいと思います。
もう 1 つのオプションは、今のところ値をハードコーディングしてから、必要に応じて前後に切り替えることですが、可能であれば、最適なソリューションが必要です。どんな情報でも大歓迎です!
更新 -- 奇妙です。もう 1 つの問題は、kaxaml と VS2008 のレンダリングが異なることです。kaxaml で次の XAML を使用する場合:
<Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Page.Resources>
<Style TargetType="{x:Type Button}">
<Setter Property="Margin" Value="3" />
<Setter Property="Width" Value="50" />
</Style>
</Page.Resources>
<DockPanel>
<StackPanel DockPanel.Dock="Bottom" Orientation="Horizontal" Height="Auto" HorizontalAlignment="Right">
<Button>Cancel</Button>
<Button>OK</Button>
</StackPanel>
<Grid DockPanel.Dock="Top">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Viewbox Grid.Row="0">
<Canvas Width="600" Height="50">
<TextBox>test</TextBox>
</Canvas>
</Viewbox>
<Viewbox Grid.Row="1">
<!-- <Canvas Width="{Binding WorkspaceWidth}" Height="{Binding WorkspaceHeight}" > -->
<Canvas Width="640" Height="480" >
<TextBox>test</TextBox>
<TextBox Canvas.Left="150" Canvas.Top="50">test</TextBox>
</Canvas>
</Viewbox>
</Grid>
</DockPanel>
</Page>
期待どおりにレンダリングされます。しかし、DockPanel を VS2008 プロジェクトにコピーすると、何も入っていない "Viewbox" 要素が得られます。誰もこれを説明できますか?