質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.50%
WPF

Windows Presentation Foundation (WPF) は、魅力的な外観のユーザー エクスペリエンスを持つ Windows クライアント アプリケーションを作成するための次世代プレゼンテーション システムです

Q&A

解決済

1回答

1438閲覧

comboboxのセレクト操作で、MainのウィンドウのTextBlock(selecteditem)のテキスト内容を書き換えたいです。

退会済みユーザー

退会済みユーザー

総合スコア0

WPF

Windows Presentation Foundation (WPF) は、魅力的な外観のユーザー エクスペリエンスを持つ Windows クライアント アプリケーションを作成するための次世代プレゼンテーション システムです

0グッド

0クリップ

投稿2016/02/28 11:00

VisualStudio2013Desktop, WPFの質問です。
MainのウィンドウからSubのウィンドウを開きました。
SubWindowにはcomboboxを配置してあります。
このcomboboxのセレクト操作で、MainのウィンドウのTextBlock(selecteditem)のテキスト内容を書き換えたいです。
どのような設定をすればよいでしょうか。
コードで教えていただけるとうれしいです。

MainWindow xaml
<Window x:Class="WPF.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="385" Width="600" Loaded="Window_Loaded" >
<Grid>
<TextBlock Name="selecteditem"/>
</Grid>
</Window>

MainWindow C#
using System;
using System.Diagnostics;
using System.Text.RegularExpressions;
using System.Threading;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Linq;
using System.Collections.Generic;
using System.Collections.ObjectModel;

namespace WPF {
public partial class MainWindow : Window {
public MainWindow() {
InitializeComponent();
}

private void Window_Loaded(object sender, RoutedEventArgs e) { WPF.window2 window = new WPF.window2(); window.Show(); }

subWindow xaml
<Window x:Class="WPF.window2" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="window2" Height="300" Width="300">
<Grid>
<ComboBox >
<TextBlock Text="1"/>
<TextBlock Text="2"/>
<TextBlock Text="3"/>
</ComboBox>
</Grid>
</Window>

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

ベストアンサー

子要素で指定しました。

投稿2016/02/29 04:20

退会済みユーザー

退会済みユーザー

総合スコア0

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.50%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問