0

これは、ExpressionBlend4でのセルテンプレートの編集について私が理解していないことです。

xamlを使用してセルテンプレートを手動で作成すると、コードは次のようになります。

<Window
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:leartWPF" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"
    x:Class="leartWPF.Window1"
    x:Name="Window"
    Title="Window1"
    Width="640" Height="480">
    <Window.Resources>
        <local:GroupDataSource x:Key="GroupDataSourceDataSource" d:IsDataSource="True"/>

    </Window.Resources>

    <Grid x:Name="LayoutRoot" Margin="0" DataContext="{Binding Source={StaticResource GroupDataSourceDataSource}}">
        <DataGrid  Margin="0" HeadersVisibility="None" ItemsSource="{Binding GroupExtednenDatas, ElementName=Window}" AutoGenerateColumns="False" RowHeight="25" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" CanUserAddRows="False" >
            <DataGrid.Columns>
                <DataGridTemplateColumn Header="Groups" Width="Auto" IsReadOnly="True" >
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                             <TextBlock Text="{Binding Name}" Width="200"></TextBlock>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
            </DataGrid.Columns>
        </DataGrid>     
    </Grid>
</Window>

これにより、ウィンドウが作成され、多かれ少なかれ大丈夫に見えます。

ここに画像の説明を入力してください

Expression Blendのメニューを使用して同じことを行おうとすると、

ここに画像の説明を入力してください

私は次のコードで終わります:

<Window
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:leartWPF" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"
    x:Class="leartWPF.Window1"
    x:Name="Window"
    Title="Window1"
    Width="640" Height="480">
    <Window.Resources>
        <local:GroupDataSource x:Key="GroupDataSourceDataSource" d:IsDataSource="True"/>
        <DataTemplate x:Key="MyDataTemplate">
            <TextBlock Text="{Binding Name}" Width="200"></TextBlock>
        </DataTemplate>

    </Window.Resources>

    <Grid x:Name="LayoutRoot" Margin="0" DataContext="{Binding Source={StaticResource GroupDataSourceDataSource}}">
        <DataGrid  Margin="0" HeadersVisibility="None" ItemsSource="{Binding GroupExtednenDatas, ElementName=Window}" AutoGenerateColumns="False" RowHeight="25" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" CanUserAddRows="False" >
            <DataGrid.Columns>
                <DataGridTemplateColumn Header="Groups" Width="Auto" IsReadOnly="True" CellTemplate="{DynamicResource MyDataTemplate}" >

                </DataGridTemplateColumn>
            </DataGrid.Columns>
        </DataGrid>     
    </Grid>
</Window>

中に何を入れても空のセルが表示されます

<DataTemplate x:Key="MyDataTemplate"> :

ここに画像の説明を入力してください

私は何か間違ったことをしますか、それともこのExpression Blendのバグですか?これがバグである場合、XAMLコードを変更して修正するにはどうすればよいですか?

4

1 に答える 1

0

もしそうなら、理解できなくて申し訳ありませんが、質問が必要なものを複雑にしすぎているようです。CellTemplate は単なるプレースホルダーです-データグリッドではデフォルトで空なので、好きなものを入れることができます->あなたの場合はTextBlockのプレースホルダーです。これは、Blend で編集する必要があるもの、または CellTemplate に配置するその他のコントロールです。

于 2012-04-10T21:17:32.937 に答える