0
データを表示するためにGridViewColumnsがいくつかあるWPFフォームがあります。ただし、各列にHeaderプロパティを設定しても、ヘッダーは表示されません。GridViewColumnHeaderが表示されない
XAML:
<Window x:Class="MyProject.ViewModel.MyClassView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vm="clr-namespace:MyProject.ViewModel"
Title="Title" Height="210.4" Width="500" ResizeMode="NoResize"
WindowStartupLocation="CenterOwner" WindowStyle="ToolWindow">
<Window.Resources>
<DataTemplate x:Key="tempA">
<TextBlock Text="{Binding Path=dataA}"/>
</DataTemplate>
<DataTemplate x:Key="tempB">
<TextBlock Text="{Binding Path=dataB}"/>
</DataTemplate>
<DataTemplate x:Key="tempC">
<TextBlock Text="{Binding Path=dataC}"/>
</DataTemplate>
</Window.Resources>
<Grid Margin="5,5,5,5">
<ListView x:Name="MyList" ItemsSource="{Binding MyDataCollection}" MouseDoubleClick="ListView_MouseDoubleClick">
<ListView.View>
<GridView>
<GridViewColumn x:Name="colA" Header="Name" Width="100" CellTemplate="{StaticResource tempA}"/>
<GridViewColumn x:Name="colB" Header="Type" Width="100" CellTemplate="{StaticResource tempB}"/>
<GridViewColumn x:Name="colC" Header="Diameter" Width="100" CellTemplate="{StaticResource tempC}"/>
</GridView>
</ListView.View>
</ListView>
</Grid>
</Window>
コードビハインド:
namespace MyProject.ViewModel
{
public partial class MyClassView : Window
{
public object SelectedItem = null;
public MyClassView()
{
InitializeComponent();
}
private void ListView_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
SelectedItem = MyList.SelectedItem;
}
}
}
のViewModel:
のViewModelコンストラクタに渡されるオブジェクトはDATAA、DATABを含むことが保証されて
namespace MyProject.ViewModel
{
public class MyViewModel : INotifyPropertyChanged
{
public string Type { get; set; }
public object MyDataCollection { get; set; }
public MyViewModel(object collection, string type)
{
Type = type;
MyDataCollection = collection;
}
internal void RaisePropertyChanged(string prop)
{
if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(prop)); }
}
public event PropertyChangedEventHandler PropertyChanged;
}
}
とデータC
誰かが私のGridViewのヘッダーが表示されない理由を説明できますか?
が私のために列ヘッダは、コードごとに表示されます。
は、それは次のようになります。 –
これは本当に多くありません...これは、別のウィンドウの子として生成されるスタンドアロンのウィンドウです。それに関連するコードはほとんどありません。コンストラクタやその他の変数定義です。 – bemailloux
あなたが持っているすべてのコードを投稿 –