2011-05-05 3 views
3

나는 내 usercontrol에 여러 항목이 있습니다. 나는 모든 것을 그리드에 넣었다. 하지만 이제는 화면의 해상도가 변경되면 창 크기가 자동으로 조정됩니다. 이것은 단지 작동하지 않습니다. 이미 뷰 박스를 사용했지만 원하는 결과가 아닙니다. 이 UserControl을이 창에서 설정wpf에서 usercontrol의 배율을 조정 하시겠습니까?

<UserControl x:Class="NewWPFVragenBeheer.Maak_toets.Views.ChangeCourse" 
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
       xmlns:converters="clr-namespace:NewWPFVragenBeheer.Converters" 
         mc:Ignorable="d" d:DesignHeight="200" d:DesignWidth="700" 
      > 

    <UserControl.Resources> 
     <XmlDataProvider x:Key="Vakken" 
       Source="C:\Users\Ruben\Desktop\Stage 26-04\stage_TFW\stage_TFW\NewWPFVragenBeheer\Data\Courses.xml" 
       XPath="/Courses/Course" 
      /> 

     <converters:RadioBoolToIntConverter x:Key="radioBoolToIntConverter" /> 
    </UserControl.Resources> 

    <Viewbox Stretch="None"> 
     <Grid > 
      <Grid.ColumnDefinitions> 
       <ColumnDefinition Width="722*" /> 
       <ColumnDefinition Width="254*" /> 
      </Grid.ColumnDefinitions> 


      <Label Content="Maximale tijd:" Height="28" FontWeight="Bold" HorizontalAlignment="Left" Margin="12,28,0,0" Name="label1" VerticalAlignment="Top" Width="177" /> 
      <TextBox Height="23" HorizontalAlignment="Left" Margin="215,30,0,0" Text="{Binding Path=MaxTime}" VerticalAlignment="Top" Width="145" /> 

      <TextBox Height="23" HorizontalAlignment="Left" Margin="215,2,0,0" Text="{Binding Path=ExamName,UpdateSourceTrigger=PropertyChanged,Mode=TwoWay}" Name="textBox1" VerticalAlignment="Top" Width="145" /> 
      <Label FontWeight="Bold" Content="Punten:" Height="28" HorizontalAlignment="Left" Margin="386,0,0,0" Name="label2" VerticalAlignment="Top" /> 
      <TextBox Height="23" Text="{Binding Path=Score,UpdateSourceTrigger=PropertyChanged,Mode=TwoWay}" HorizontalAlignment="Left" Margin="567,2,0,0" Name="textBox2" VerticalAlignment="Top" Width="120" /> 
      <Label Content="{Binding Path= FeedbackText, UpdateSourceTrigger=PropertyChanged,Mode=TwoWay}" Height="28" HorizontalAlignment="Right" Margin="0,153,527,0" Name="label3" VerticalAlignment="Top" Width="200" Foreground="#FFF50D0D" /> 

     </Grid> 
    </Viewbox> 
</UserControl> 

:

<Window x:Class="NewWPFVragenBeheer.MaakToetsDialog" 
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
     xmlns:view="clr-namespace:NewWPFVragenBeheer.Views" 
     Title="MaakToetsDialog" 
     WindowStyle ="SingleBorderWindow" 
     WindowState ="Maximized" 
     WindowStartupLocation="CenterScreen"   
     > 


    <view:MaakToetsView /> 
</Window> 

누군가 도와주세요 이 내 UserControl을합니다.

+0

시각적으로 어떻게 비율을 조정할 수 있습니까? –

답변

1

격자를 고정 폭과 높이로 설정하고 ViewBox.Stretch를 균일로 설정하십시오. 그렇게해야합니다.

+0

나는 이것을했다. 그러나 비머를 사용할 때 화면 해상도를 변경하면 그리드가 전체 화면을 채우지 못합니다 ... – Ruben

+0

@ 루벤 : 비머는 언어가 아닌 곳에서 사용해야하는 단어가 아닙니다. (어리석은 앵글리즘으로) '올바른'단어는 "프로젝터"가 될 것입니다. –

+0

@Ruben : 이상한 일입니다.하지만 새 화면 해상도에서 창이 최대화되고 (여러 화면이 겹치지 않습니다)? (나는 "비머 (beamer)"를 사용하기도하지만, 제 2 언어는 그렇다) – Jens

0

정답은 찾는 솔루션보다 복잡 할 수 있지만이를 짧게 유지하려고합니다.

내 경험에 가장 좋은 방법은 그리드를 기본 요소로 사용하고 그리드 (또는 그 안의 다른 그리드) 내에 컨트롤을 배치하고 뷰 박스에 개별 컨트롤을 래핑하는 것입니다. 그런 다음 UserControl SizeChanged 이벤트를 UserControl의 높이와 너비가 적절한 비율을 유지하도록하는 메서드에 연결합니다.

이것이 내 WPF UI에서 처리하는 가장 좋은 방법입니다.

관련 문제