0
私はWPFで新しく問題をスタックしています。私はDataContext
とグリッドを持っていますListView
選択項目にバインドします。 1つのXAMLファイルにすべてが含まれている場合の作業です。 UserControl
にグリッドを移動した後にバインディングを保存するにはどうすればよいですか?WPFのMainWindow要素にUserControlをバインドします
ユーザーコントロール:
<UserControl x:Class="Books.Views.BookView"
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:local="clr-namespace:Books.Views"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid DataContext="{Binding SelectedValue, ElementName=booksGrid}">
...
</Grid>
</UserControl>
は、メインウィンドウ:
...
<ListView x:Name="booksGrid" ItemsSource="{Binding}">
...
<ContentControl Name="infoControl"
Grid.Row="0"
Grid.Column="1"
Content="{Binding}" />