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 796865
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T22:42:26+00:00 2026-05-14T22:42:26+00:00

<UserControl x:Class=SLGridImage.MainPage 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 mc:Ignorable=d d:DesignHeight=300 d:DesignWidth=400 xmlns:sdk=http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk> <UserControl.Resources> <local:LevelToVisibilityConverter x:Key=LevelToVisibility />

  • 0
<UserControl x:Class="SLGridImage.MainPage"
    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"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400" xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk">

    <UserControl.Resources>
        <local:LevelToVisibilityConverter x:Key="LevelToVisibility" />
    </UserControl.Resources>


    <Grid x:Name="LayoutRoot" Background="White">
        <sdk:DataGrid x:Name="dgMarks"  CanUserResizeColumns="False"  SelectionMode="Single" 
               AutoGenerateColumns="False" 
                      VerticalAlignment="Top" 
                      ItemsSource="{Binding MarkCollection}"
                      IsReadOnly="True"  
                      Margin="13,44,0,0" 
                      RowDetailsVisibilityMode="Collapsed" Height="391" 
                      HorizontalAlignment="Left" Width="965" 
                      VerticalScrollBarVisibility="Visible" >
            <sdk:DataGrid.Columns>
                <sdk:DataGridTemplateColumn>
                    <sdk:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Button x:Name="myButton"   
                            Click="myButton_Click">
                                <StackPanel Orientation="Horizontal">
                                    <Image Margin="2, 2, 2, 2"  x:Name="imgMarks"  Stretch="Fill" Width="12" Height="12" 
                                           Source="Images/test.png"
                                           VerticalAlignment="Center"
                                           HorizontalAlignment="Center"
                                        Visibility="{Binding Level, Converter={StaticResource LevelToVisibility}}"
                                     />
                                    <TextBlock Text="{Binding Level}" TextWrapping="NoWrap"  ></TextBlock>

                                </StackPanel>
                            </Button>
                        </DataTemplate>
                    </sdk:DataGridTemplateColumn.CellTemplate>
                </sdk:DataGridTemplateColumn>
                <sdk:DataGridTemplateColumn  Header="Name" >
                    <sdk:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate >
                            <Border>
                                <TextBlock Text="{Binding Name}" />
                            </Border>
                        </DataTemplate>
                    </sdk:DataGridTemplateColumn.CellTemplate>
                </sdk:DataGridTemplateColumn>

                <sdk:DataGridTemplateColumn  Header="Marks" Width="80">
                    <sdk:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Border>
                                <TextBlock Text="{Binding Marks}" />
                            </Border>
                        </DataTemplate>
                    </sdk:DataGridTemplateColumn.CellTemplate>
                </sdk:DataGridTemplateColumn>
            </sdk:DataGrid.Columns>
        </sdk:DataGrid>
    </Grid>
</UserControl>

in .cs :

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections.ObjectModel;
using System.ComponentModel;

namespace SLGridImage
{
    public partial class MainPage : UserControl
    {
        private MarksViewModel model = new MarksViewModel();
        public MainPage()
        {
            InitializeComponent();
            this.DataContext = model;
        }

        private void myButton_Click(object sender, RoutedEventArgs e)
        {

        }
    }

    public class MarksViewModel : INotifyPropertyChanged
    {

        public MarksViewModel()
        {
            markCollection.Add(new Mark() { Name = "ABC", Marks = 23, Level = 0 });
            markCollection.Add(new Mark() { Name = "XYZ", Marks = 67, Level = 1 });
            markCollection.Add(new Mark() { Name = "YU", Marks = 56, Level = 0 });
            markCollection.Add(new Mark() { Name = "AAA", Marks = 89, Level = 1 });
        }


        private ObservableCollection<Mark> markCollection = new ObservableCollection<Mark>();
        public ObservableCollection<Mark> MarkCollection
        {
            get { return this.markCollection; }
            set
            {
                this.markCollection = value;
                OnPropertyChanged("MarkCollection");
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;

        public void OnPropertyChanged(string propName)
        {
            if (PropertyChanged != null)
                this.PropertyChanged(this, new PropertyChangedEventArgs(propName));
        }
    }

    public class Mark
    {
        public string Name { get; set; }
        public int Marks { get; set; }
        public int Level { get; set; }
    }

    public class LevelToVisibilityConverter : System.Windows.Data.IValueConverter
    {
        #region IValueConverter Members

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            Visibility isVisible = Visibility.Collapsed;
            if ((value == null))
                return isVisible;
            int condition = (int)value;
            isVisible = condition == 1 ? Visibility.Visible : Visibility.Collapsed;
            return isVisible;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }

        #endregion
    }
}

when i run getting error at this line

<UserControl.Resources>
        <local:LevelToVisibilityConverter x:Key="LevelToVisibility" />
    </UserControl.Resources>

The type ‘local:LevelToVisibilityConverter’ was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built.

What I am I missing here?
Looking forward for an solution, thank you.

  • 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-14T22:42:27+00:00Added an answer on May 14, 2026 at 10:42 pm

    You need to include the Xml-Namespace of the Namespace where your LevelToVisibilityConverter is in your Assembly.

    Assume your LevelToVisibilityConverter is in Namespace SLGridImage you have to add the XML-Namespace (xmlns:local=”clr-namespace:SLGridImage”) as follows

    <UserControl x:Class="SLGridImage.MainPage"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:local="clr-namespace:SLGridImage"
      <!-- Rest of the declaration -->
    >
    </UserControl>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class which implements UserControl. In .NET 2005, a Dispose method is
I've made a class which inherits from UserControl, but which I only want to
I've got the following Generic usercontrol declared: public partial class MessageBase<T> : UserControl {
I'm trying to create a UserControl that inherits from a generic class. It does
In Silverlight I noticed that the code-behind Page class inherits from UserControl: public partial
The UserControl class inherits from TemplateControl which implements INamingContainer. Since this is only a
I have a UserControl class in a Windows Application project. One of the properties
I've got a usercontrol which inherits from the UserControl class. There are a bunch
is there a way to have a WPF UserControl Class to be a class
I’m creating a UserControl for a rich TreeView (one that has context menus for

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.