0

如何添加属性Namex:Name此 XAML 代码(在组合框中):

<DataGridTemplateColumn Header="Status">
    <DataGridTemplateColumn.CellTemplate>
        <DataTemplate>
            <TextBlock VerticalAlignment="Center" Text="{Binding name_ru}" Width="Auto" />
        </DataTemplate>
    </DataGridTemplateColumn.CellTemplate>
    <DataGridTemplateColumn.CellEditingTemplate>
        <DataTemplate>
            <ComboBox Style="{DynamicResource ComboBoxStyle}" SelectionChanged="status_SelectionChanged" Height="auto" Width="Auto">
                 <ComboBox.BorderBrush>
                     <SolidColorBrush Color="{DynamicResource Color1}"/>
                 </ComboBox.BorderBrush>
            </ComboBox>
        </DataTemplate>
    </DataGridTemplateColumn.CellEditingTemplate>
</DataGridTemplateColumn>

Click以及如何在此 XAML 代码中添加事件或其他:

<!--Clien-->
<DataGridTemplateColumn Header="Client name" HeaderStyle="{DynamicResource DataGridColumnHeaderStyle1}">
    <DataGridTemplateColumn.CellTemplate>
        <DataTemplate>
            <TextBlock  VerticalAlignment="Center" Text="{Binding user_name}"  Width="Auto" Height="Auto" />
        </DataTemplate>
    </DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<!--end Clien-->

我的顶级 xaml:

<Window
  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:Microsoft_Windows_Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Classic"
       xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
        xmlns:ee="http://schemas.microsoft.com/expression/2010/effects"
         xmlns:System="clr-namespace:System;assembly=mscorlib"
          mc:Ignorable="d"
    x:Class="JanPizza.IndexFormPizza"
    x:Name="MainWnd"
    Title="MainWindow"
    MouseLeftButtonDown="MainWnd_MouseLeftButtonDown"
    ResizeMode="CanResizeWithGrip"
    xmlns:wpftoolkit="http://schemas.microsoft.com/wpf/2008/toolkit"
    xmlns:filter="clr-namespace:DataGridFilterLibrary;assembly=DataGridFilterLibrary"    

    Width="1065" Height="674" Background="{x:Null}" BorderThickness="0" Margin="5" WindowStartupLocation="CenterScreen" Foreground="#FF2D2D2D" Icon="wnd-icon.png" Style="{DynamicResource WindowStyle}" AllowsTransparency="True" WindowStyle="None" AllowDrop="False">
4

1 回答 1

0

只需使用以下属性:

<ComboBox Name="myCombobox" ... /> <TextBlock MouseLeftButtonDown="textblock_mouseLeftButtonDown" ... />
于 2012-07-11T07:44:14.823 回答