关于比例文本框的wpf问题

时间:2011-01-13 03:07:50

标签: wpf textbox

<Slider Name="photoZoomSlider" Width="180" Minimum="100" Maximum="700" Value="300" />
        <ScrollViewer   >
            <Viewbox  Width="{Binding ElementName=photoZoomSlider, Path=Value}" Height="{Binding ElementName=photoZoomSlider, Path=Value}">
                <StackPanel>
                <Image Name="Photo"  Source="C:\dic.bmp" Width="100" Height="100"/>
                    <TextBox Width="100"></TextBox>
                     <TextBox Width="200"  Padding="5"></TextBox>
                    <TextBox Width="10"></TextBox>
                    <TextBox Width="500"></TextBox>
                </StackPanel>
                <!--<Viewbox.LayoutTransform>
                    <ScaleTransform x:Name="uiZoomTransform"
                    ScaleX="{Binding ElementName=photoZoomSlider, Path=Value}"
                   ScaleY="{Binding ElementName=photoZoomSlider, Path=Value}"/>
                </Viewbox.LayoutTransform>-->

            </Viewbox>
        </ScrollViewer>
    </StackPanel>

调整滑块,当我单击textBox时,TextBox无法显示焦点,请,如何解决? 谢谢!

1 个答案:

答案 0 :(得分:0)

我试过你给的东西,经过一些小的调整就可以了:

<StackPanel>
        <Slider Name="photoZoomSlider" Width="200" Height="50" Value="50" />
        <ScrollViewer>
            <Viewbox  Width="{Binding ElementName=photoZoomSlider, Path=Value}" Height="{Binding ElementName=photoZoomSlider, Path=Value}">
                <StackPanel>
                    <TextBox Text="ff" />
                    <TextBox Text="ss" />
                    <TextBox Text="zz" />
                    <TextBox Text="cc" />
                </StackPanel>
                <Viewbox.LayoutTransform>
                    <ScaleTransform x:Name="uiZoomTransform" ScaleX="{Binding ElementName=photoZoomSlider, Path=Value}"
                        ScaleY="{Binding ElementName=photoZoomSlider, Path=Value}"/>
                </Viewbox.LayoutTransform>

            </Viewbox>
        </ScrollViewer>
    </StackPanel>