Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7608827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:01:11+00:00 2026-05-31T01:01:11+00:00

I am new to WPF and entity framework. I have ran into the the

  • 0

I am new to WPF and entity framework. I have ran into the the following problem while working on an application. In my application I am binding my data using collection view source from entity framework. one of my database table has a column named isNumeric datatype Boolean. if its is true then my grid view in WPF window should show the text “Numeric” and “String” if false. For this requirement I cant directly bind the my linq query result with the grid view or any control in the UI. Any thoughts on how could I solve this.
Here some of my codes

MainWindow.XAML.cs code

 public partial class MainWindow : Window
{
    public MainWindow()
    {
        InitializeComponent();
    }

    private PartNumbersEntities partNumberContext = new PartNumbersEntities();
    private PartNumbersCollection partNumberData;
    //private PartClassesCollection partClassData;
    private CollectionViewSource MasterViewSource;

    private void Window_Loaded(object sender, RoutedEventArgs e)
    {
        //string classFilter = classNameTextBox.Text;
        //if (classFilter.Length == 0)
            classFilter = "Dis";
        //MessageBox.Show(classFilter);
        var result = partNumberContext.PartNumbers.Where(p => p.PartClass.chrPCName.Contains(classFilter)).Select(p => p);    

        this.partNumberData = new PartNumbersCollection(result, partNumberContext);
        this.MasterViewSource = (CollectionViewSource)this.FindResource("MasterView");
        this.MasterViewSource.Source = this.partNumberData;           
    }

}

My partNumber Collection

class PartNumbersCollection : ObservableCollection<PartNumber>
{
    private PartNumbersEntities _context;
    public PartNumbersEntities Context
    {
        get { return _context; }
    }


    public PartNumbersCollection(IEnumerable<PartNumber> partNumbers, PartNumbersEntities context)
        : base(partNumbers)
    {
        _context = context;

    }
}

Xaml Code

<Window x:Class="Engenious.PartNumbersUI.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="454" Width="1033" Loaded="Window_Loaded">

<Window.Resources>
    <CollectionViewSource x:Key="MasterView" />
    <CollectionViewSource x:Key="PartProperties" 
        Source="{Binding Source={StaticResource MasterView}, 
        Path='PartProperties'}"/>
    <!--<CollectionViewSource x:Key="PartNumberView" 
        Source="{Binding Source={StaticResource MasterView}, 
        Path='PartNumbers'}"/>-->
</Window.Resources>
<Grid DataContext="{Binding Source={StaticResource MasterView}}">
    <Grid.RowDefinitions>
        <RowDefinition Height="42" />
        <RowDefinition Height="310" />
        <RowDefinition Height="42" />            
    </Grid.RowDefinitions>
    <Grid Grid.Row="0" Name="Grid0">
        <StackPanel Name="StackPanel1" Orientation="Horizontal">
            <Label Content="Class Filter" Height="28" Name="label1" Margin="3" />
            <TextBox Height="28" Name="classNameTextBox" Width="120" Margin="3"/>
            <Button Content="Apply" Height="28" Name="applyButton" Width="80" Margin="3"/>
        </StackPanel>
    </Grid>
    <ListView Grid.Row="1" Name="ListView1" VerticalContentAlignment="Top" 
              VerticalAlignment="Top" HorizontalAlignment="Left" Height="310" 
              Width="320"
              IsSynchronizedWithCurrentItem="True"
              ItemsSource="{Binding }">
        <ListView.ItemContainerStyle>
            <Style TargetType="ListViewItem">
                <Setter Property="HorizontalContentAlignment" Value="Stretch" />
            </Style>
        </ListView.ItemContainerStyle>
        <ListView.View>
            <GridView>
                <GridViewColumn Header="Part Class Name" Width="150">
                    <GridViewColumn.CellTemplate>
                        <DataTemplate>
                            <Label Content="{Binding Path=PartClass.chrPCName}"  Margin="-6,0,-6,0"/>                                
                        </DataTemplate>
                    </GridViewColumn.CellTemplate>
                </GridViewColumn>                    

                <GridViewColumn Header="Part Number" Width="130">
                    <GridViewColumn.CellTemplate>
                        <DataTemplate>
                            <!--<Label Content="{Binding Source={StaticResource PartNumberView},Path=chrPNPartNumber}" Margin="-6,0,-6,0"/>-->
                            <Label Content="{Binding Path=chrPNPartNumber}" Margin="-6,0,-6,0"/>
                        </DataTemplate>
                    </GridViewColumn.CellTemplate>
                </GridViewColumn>

            </GridView>
        </ListView.View>
    </ListView>

    <ListView Grid.Row="1" Height="310" HorizontalAlignment="Left" Margin="350,0,0,0" Name="listView2"
              VerticalAlignment="Top" Width="375"
              IsSynchronizedWithCurrentItem="True"
              ItemsSource="{Binding Source={StaticResource  PartProperties}}">
        <ListView.ItemContainerStyle>
            <Style TargetType="ListViewItem">
                <Setter Property="HorizontalContentAlignment" Value="Stretch" />
            </Style>
        </ListView.ItemContainerStyle>
        <ListView.View>
            <GridView>
                <GridViewColumn Header="Name" Width="150">
                    <GridViewColumn.CellTemplate>
                        <DataTemplate>
                            <Label Content="{Binding Path=ConfigurationProperty.chrCPProperty}"  Margin="-6,0,-6,0"/>
                        </DataTemplate>
                    </GridViewColumn.CellTemplate>
                </GridViewColumn>

                <GridViewColumn Header="Datatype" Width="130">
                    <GridViewColumn.CellTemplate>
                        <DataTemplate>
                            <Label Content="{Binding Path=ConfigurationProperty.bitCPIsNumeric}" Margin="-6,0,-6,0"/>
                        </DataTemplate>
                    </GridViewColumn.CellTemplate>
                </GridViewColumn>

            </GridView>
        </ListView.View>




    </ListView>
    <StackPanel Name="StackPanel4" Orientation="Horizontal" Grid.Row="2">
        <Button Height="25" Name="btnAddDetail" Width="82" Margin="3">Save</Button>
        <Button Height="26" Name="btnDeleteDetail" Width="83" Margin="3">Delete</Button>
    </StackPanel>

</Grid>

Here is a Screen shot
enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T01:01:13+00:00Added an answer on May 31, 2026 at 1:01 am

    I have used data Trigger to solve this problem..
    Here is my XAML for it.

    <GridViewColumn Header="Datatype" Width="130">
                        <GridViewColumn.CellTemplate>
                            <DataTemplate >
    
                                <Label>
                                    <Label.Resources>
                                        <Style TargetType="{x:Type Label}">
                                            <Style.Triggers>
                                                <DataTrigger Binding="{Binding Path = 'ConfigurationProperty.bitCPIsNumeric'}" Value="True">
                                                    <Setter Property="Content" Value="Numeric" />
                                                </DataTrigger>
                                                <DataTrigger Binding="{Binding Path = 'ConfigurationProperty.bitCPIsNumeric'}" Value="False">
                                                    <Setter Property="Content" Value="String" />
                                                </DataTrigger>
                                            </Style.Triggers>
                                        </Style>
                                    </Label.Resources>
                                </Label>
    
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on a WPF application using Entity Framework 4.0. When I tried
I have been using a lot Entity Framework in a MVVM WPF application recently
While designing a new WPF application I noticed exceptions not being thrown during data
I'm new to WPF and data binding so hopefully I can explain the problem
I have an application that uses Entity Framework to access the data, and throughout
I am using Entity Framework and SQL CE 4.0 with my WPF application. How
I am new to WPF and entity framework. In my application I want to
using WPF/C#/Entity Framework. I have a DataGrid.ItemsSource bound to some ObservableCollection . Now, I
Goal: To use entity framework with N-tier in my WPF application. Problem: I can't
I have a WPF application in which I use entity framework with mysql connector/net

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.