Quantcast
Channel: wpftoolkit Discussions Rss Feed
Viewing all articles
Browse latest Browse all 2157

New Post: CheckComboBox

$
0
0
Hi, Based on your sample, it worked for me. I can see the name of the routes in the CheckComboBox.
Here's my sample :
<Window x:Class="WpfApplication82.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
        xmlns:xcdg="http://schemas.xceed.com/wpf/xaml/datagrid"
        xmlns:local="clr-namespace:WpfApplication82"
        Title="MainWindow" Height="350" Width="525">
   <Window.Resources>
      <local:Routes x:Key="Routes" />
      <CollectionViewSource x:Key="RouteCollectionViewSource"
                            Source="{Binding Source={StaticResource Routes}, Path=RouteList}" />
      
      <xcdg:CellEditor x:Key="DataGridCheckComboBoxCellEditor">
         <xcdg:CellEditor.EditTemplate>
            <DataTemplate>
               <xctk:CheckComboBox HorizontalAlignment="Stretch"
                                   VerticalAlignment="Center"
                                   DisplayMemberPath="{Binding RelativeSource={RelativeSource Self}, Path=(xcdg:Cell.CellEditorContext).ForeignKeyConfiguration.DisplayMemberPath,Mode=OneWay}"
                                   ItemsSource="{Binding RelativeSource={RelativeSource Self}, Path=(xcdg:Cell.CellEditorContext).ForeignKeyConfiguration.ItemsSource, Mode=OneWay}"
                                   SelectedValue="{xcdg:CellEditorBinding}"
                                   ValueMemberPath="{Binding RelativeSource={RelativeSource Self}, Path=(xcdg:Cell.CellEditorContext).ForeignKeyConfiguration.ValuePath}" />
            </DataTemplate>
         </xcdg:CellEditor.EditTemplate>
      </xcdg:CellEditor>
   </Window.Resources>
   <Grid>
      <xcdg:DataGridControl x:Name="_dataGrid">
         <xcdg:DataGridControl.Columns>
            <xcdg:Column Title="Routes"
                         FieldName="ConflictedRoutes"
                         CellEditor="{StaticResource DataGridCheckComboBoxCellEditor}"
                         AllowGroup="False"
                         AllowSort="False"
                         CellEditorDisplayConditions="Always">
               <xcdg:Column.ForeignKeyConfiguration>
                  <xcdg:ForeignKeyConfiguration ItemsSource="{Binding Source={StaticResource RouteCollectionViewSource}}"
                                                DisplayMemberPath="Name"
                                                ValuePath="Index" />
               </xcdg:Column.ForeignKeyConfiguration>

            </xcdg:Column>
         </xcdg:DataGridControl.Columns>
      </xcdg:DataGridControl>
   </Grid>
</Window>

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

      _dataGrid.ItemsSource = new List<MyData>()
      {
        new MyData(),
        new MyData()
      };
    } 
  }

  public class MyData
  {
    public object ConflictedRoutes
    {
      get;
      set;
    }
  }

  public class Route
  {
    public string Name
    {
      get;
      set;
    }

    public int Index
    {
      get;
      set;
    }

    public Route()
    {
    }
  }

  public class Routes
  {
    ObservableCollection<Route> _routeList = new ObservableCollection<Route>();

    public ObservableCollection<Route> RouteList
    {
      get
      {
        return _routeList;
      }
    }

    public Routes()
    {
      _routeList.Add( new Route() { Index = 0, Name = "First Route" } );
      _routeList.Add( new Route() { Index = 1, Name = "Second Route" } );
      _routeList.Add( new Route() { Index = 2, Name = "Third Route" } );
      _routeList.Add( new Route() { Index = 3, Name = "Fourth Route" } );
    }
  }
}

Viewing all articles
Browse latest Browse all 2157

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>