2017-01-12 5 views
1

다른 WPF에 넣어 정보에서 WPF의 값/열린 파일을 넣어 내 문제는 그 다음이다 : 나는 버튼, textBoxs 등으로 WPF를 사용하고 싶습니다당신은 내가 C#으로 시작하고있어

.. 다른 WPF에서 정보와 비디오를 제어 (표시).

하지만 다른 WPF와 제대로 상호 작용하는 방법을 찾을 수 없습니다. 내 WPF 창

코드 :

<Window x:Class="WPF_AVC.MainWindow" 
    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:local="clr-namespace:WPF_AVC" 
    mc:Ignorable="d" 
    Title="ConfiguratorAVC" Height="350" Width="525"> 
<Grid Background="Black"> 
    <TextBox x:Name="textBox" HorizontalAlignment="Center" Height="22" Margin="0,48,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="120" Background="Black" BorderBrush="#FF707070" Foreground="#FF707071" SelectionBrush="Black" TextChanged="textBox_TextChanged" KeyDown="OnKeyDownHandler"/> 
    <TextBlock x:Name="textBlock" HorizontalAlignment="Center" Margin="0,32,0,0" TextWrapping="Wrap" Text="Entrez un mot" VerticalAlignment="Top" Width="120" Foreground="#FF707071" TextAlignment="Center"/> 
    <Button x:Name="generate_words_btn" Content="Generer hologramme" HorizontalAlignment="Center" Margin="0,76,0,0" VerticalAlignment="Top" Width="120" Background="Black" Foreground="#FF707070" Click="generate_words_btn_Click"/> 
    <Border Margin="0,267,-0.2,22" HorizontalAlignment="Center"> 
     <Grid> 
      <Button x:Name="Pay_btn" Content="►" HorizontalAlignment="Center" Margin="0,0,243,0" VerticalAlignment="Top" Width="74" Background="Black" FontWeight="Bold" Foreground="#FF707071" HorizontalContentAlignment="Center" Height="30" Click="Pay_btn_Click" OpacityMask="Black"> 
       <Button.BindingGroup> 
        <BindingGroup/> 
       </Button.BindingGroup> 
      </Button> 
      <Button x:Name="Stop_btn" Content="■" HorizontalAlignment="Center" Margin="160,0,81,0" VerticalAlignment="Top" Width="76" Background="Black" FontWeight="Bold" Foreground="#FF707071" HorizontalContentAlignment="Center" Height="30" Click="Stop_btn_Click"> 
       <Button.BindingGroup> 
        <BindingGroup/> 
       </Button.BindingGroup> 
      </Button> 
      <Button x:Name="Pause_btn" Content="❚❚" HorizontalAlignment="Center" Margin="79,0,162,0" VerticalAlignment="Center" Width="76" Background="Black" FontWeight="Bold" Foreground="#FF707071" HorizontalContentAlignment="Center" Height="30" Click="Pause_btn_Click"> 
       <Button.BindingGroup> 
        <BindingGroup/> 
       </Button.BindingGroup> 
      </Button> 
      <Button x:Name="Open_btn" Content="Open" HorizontalAlignment="Center" Margin="241,0,0,0" VerticalAlignment="Top" Width="76" Background="Black" FontWeight="Bold" Foreground="#FF707071" HorizontalContentAlignment="Center" Height="30" Click="Open_btn_Click" OpacityMask="Black"> 
       <Button.BindingGroup> 
        <BindingGroup/> 
       </Button.BindingGroup> 
      </Button> 
     </Grid> 
    </Border> 
    <ListBox x:Name="listBox" HorizontalAlignment="Left" Height="84" Margin="53,120,0,0" VerticalAlignment="Top" Width="100" Background="Black" BorderBrush="#FF707070"> 
     <ListBoxItem Content="Iron Man" Foreground="#FF707071" Selected="ListBoxItem_Selected"/> 
     <ListBoxItem Content="Daft Punk" Foreground="#FF707071" Selected="ListBoxItem_Selected_1"/> 
     <ListBoxItem Content="Link Shield" Foreground="#FF707071" Selected="ListBoxItem_Selected_2"/> 
     <ListBoxItem Content="Anonymous" Foreground="#FF707071" Selected="ListBoxItem_Selected_3"/> 
    </ListBox> 

</Grid> 

<Window x:Name="holoAvcWindow" x:Class="WPF_AVC.DisplaynWindow" 
    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:local="clr-namespace:WPF_AVC" 
    mc:Ignorable="d" 
    Title="HoloAVC" Height="950.333" Width="1600" Background="Black" WindowStyle="ToolWindow" SnapsToDevicePixels="True" ResizeMode="NoResize" WindowStartupLocation="CenterScreen" > 
<Window.BindingGroup> 
    <BindingGroup/> 
</Window.BindingGroup> 
<Grid> 
    <MediaElement x:Name="mediaElement" HorizontalAlignment="Center" Height="720" Margin="0" VerticalAlignment="Center" Width="1280"/> 
    <Grid Margin="336,0,336,50"> 
     <MediaElement x:Name="videoDisplayElement" Height="300" VerticalAlignment="Top" Margin="0,311,622,0" RenderTransformOrigin="0.5,0.5" OpacityMask="Black"> 
      <MediaElement.RenderTransform> 
       <TransformGroup> 
        <ScaleTransform/> 
        <SkewTransform/> 
        <RotateTransform Angle="-90"/> 
        <TranslateTransform/> 
       </TransformGroup> 
      </MediaElement.RenderTransform> 
     </MediaElement> 
     <MediaElement x:Name="videoDisplayElement_Copy" HorizontalAlignment="Center" Height="300" Width="300" Margin="311,622,311,0" RenderTransformOrigin="0.5,0.5" OpacityMask="Black" VerticalAlignment="Top"> 
      <MediaElement.RenderTransform> 
       <TransformGroup> 
        <ScaleTransform/> 
        <SkewTransform/> 
        <RotateTransform Angle="180"/> 
        <TranslateTransform/> 
       </TransformGroup> 
      </MediaElement.RenderTransform> 
     </MediaElement> 
     <MediaElement x:Name="videoDisplayElement_Copy1" HorizontalAlignment="Center" Height="300" VerticalAlignment="Top" Width="300" Margin="311,0" OpacityMask="Black"/> 
     <MediaElement x:Name="videoDisplayElement_Copy2" HorizontalAlignment="Left" Height="300" VerticalAlignment="Top" Width="300" Margin="622,311,0,0" RenderTransformOrigin="0.5,0.5" OpacityMask="Black"> 
      <MediaElement.RenderTransform> 
       <TransformGroup> 
        <ScaleTransform/> 
        <SkewTransform/> 
        <RotateTransform Angle="+90"/> 
        <TranslateTransform/> 
       </TransformGroup> 
      </MediaElement.RenderTransform> 
     </MediaElement> 
     <TextBlock x:Name="textBlock2" HorizontalAlignment="Left" Margin="60,371,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Foreground="White" FontSize="48" Width="300" Height="180" RenderTransformOrigin="0.5,0.5" TextAlignment="Center"> 
      <TextBlock.RenderTransform> 
       <TransformGroup> 
        <ScaleTransform/> 
        <SkewTransform/> 
        <RotateTransform Angle="-90"/> 
        <TranslateTransform/> 
       </TransformGroup> 
      </TextBlock.RenderTransform> 
     </TextBlock> 
    </Grid> 
    <TextBlock x:Name="textBlock1" HorizontalAlignment="Left" Margin="647,120,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Foreground="White" FontSize="48" Width="300" Height="180" TextAlignment="Center"/> 
    <TextBlock x:Name="textBlock3" HorizontalAlignment="Left" Margin="898,371,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Foreground="White" FontSize="48" Width="300" Height="180" RenderTransformOrigin="0.5,0.5" TextAlignment="Center"> 
     <TextBlock.RenderTransform> 
      <TransformGroup> 
       <ScaleTransform/> 
       <SkewTransform/> 
       <RotateTransform Angle="90"/> 
       <TranslateTransform/> 
      </TransformGroup> 
     </TextBlock.RenderTransform> 
    </TextBlock> 
    <TextBlock x:Name="textBlock4" HorizontalAlignment="Left" Margin="647,622,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Foreground="White" FontSize="48" Width="300" Height="180 
       " RenderTransformOrigin="0.5,0.5" TextAlignment="Center"> 
     <TextBlock.RenderTransform> 
      <TransformGroup> 
       <ScaleTransform/> 
       <SkewTransform/> 
       <RotateTransform Angle="180"/> 
       <TranslateTransform/> 
      </TransformGroup> 
     </TextBlock.RenderTransform> 
    </TextBlock> 
</Grid> 

나는 코드가 위의 최적화되지 않은 것을 알고있다.

첫 번째 WPF의 입력에서 두 번째 WPF의 비디오를 어떻게 표시 할 수 있는지 알고 싶습니다.

감사합니다.

+0

디스플레이와 동일한 창에서 컨트롤을 사용하는 대신 별도의 창을 사용하는 특별한 이유가 있습니까? 어쨌든 - 여기에서 첫 번째에서 두 번째 wpf 창을 시작하는 데 도움이됩니다 - http://stackoverflow.com/questions/11133947/how-to-open-second-window-from-first-window-in-wpf- 두 번째 창의 컨트롤이 변수를 통해 액세스 할 수있는 것보다 공용 인 한. – PaulF

+0

이유는 그들이 의사 소통을하는 방법을 배우는 것입니다. 컨트롤 패널과 디스플레이 창 (컨트롤 패널은 열려 있어야하며 뷰 패널에 동적 변경을해야합니다). 나는 MVVM에 대해 이야기하는 것을 보았으므로이 방향을 찾고있다. 그러나 내 문제에 적응하는 방법을 거의 볼 수 없다. –

답변

0

할 수있는 일이 많습니다. 은 "플레이"버튼은 play_btn이라는에 클릭 이벤트를 추가 할 수 있습니다 WPF 두 번째를 열 경우 :

private void Play_btn_Click(object sender, RoutedEventArgs e) 
{ 
holoAvcWindow avc = new holoAvcWindow(); 
avc.Show(); 
this.Close(); 
} 

을 아니면 .ShowDialog();을 할 수있는 당신이 모두 개방하려는 경우 this.Close();를 작성하지 않지만, 사용자 원 두 번째 화면을 닫지 않으면 첫 번째 화면을 사용할 수 없습니다. 또는 this.Close();을 삭제하고 .Show();을 그대로 사용하십시오. 이 방법으로 사용자는 동시에 두 가지를 모두 사용할 수 있습니다.

그래서 우리는이 :

  • .Show()와 this.Close()를 : 첫 번째 화면을 닫고 holoAcvWindow 표시됩니다. 개방와 사용자가 모두 사용할 수있을 것입니다 모두 유지됩니다 this.Close없이

  • .Show()가()하지 않는 것이 좋습니다. 두 번째 창을 여는 단추가 있으면 사용자가 원하는 경우 1000 개의 창을 열 수 있기 때문에 최선의 선택이 아닙니다.

  • .ShowDialog() : 두 번째 holoAvcWindow가 열립니다. MainWindow를 열어 두지 만 holoAvcWindow가 닫혀 있지 않으면 사용자는 사용자를 볼 수 없습니다. 거기에 아무것도 경우

또한, 당신은 단지 매개 변수를 필요로하는 inicialized 방법을 만들고, 두 번째, 예를 들어, URL로 앞을 향해 열린 길을 건너을 보낼 수있는 초기 화면이 필요합니다.마찬가지로 :

public holoAvcWindow(string url) 
{ 
    InitializeComponent(); 
} 

및 전화 같은 두 번째 화면 :

 holoAvcWindow avc = new holoAvcWindow(url); 
     avc.Show(); 
: 당신이 두 화면이 프로그램이로드 될 때 열하려면

private void Play_btn_Click(object sender, RoutedEventArgs e) 
{ 
     holoAvcWindow avc = new holoAvcWindow(url); 
     avc.Show(); 
     this.Close(); 
} 

는, 메인 윈도우의 방법을 초기화하기 위해 추가

은 다음과 같아야합니다

public MainWindow() 
{ 
    InitializeComponent(); 
    holoAvcWindow avc = new holoAvcWindow(); 
    avc.Show(); 
} 
+0

프로그램을 시작할 때 두 창을 모두 열고 싶습니다. 재생 일시 중지 및 중지 버튼은 동영상을 제어하는 ​​용도로만 사용됩니다. 목록에서 비디오를 선택하고 재생 버튼을 누르면 비디오가 시작됩니다. 텍스트 보는 텍스트를 디스플레이 윈도우의 텍스트 블록에 표시합니다. 컨트롤 WPF 창에서 텍스트와 비디오를 모두 "새로 고침"/ 변경하고 싶습니다. –

+0

프로그램이 초기화 될 때 두 창을 모두 가지고있는 방법으로 답변이 업데이트되었습니다. – Pelicer

+0

감사합니다. 나는 시도 할 것이다! –