Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
M

Meshack Musundi

@Meshack Musundi
About
Posts
71
Topics
16
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • OCR Anyone?
    M Meshack Musundi

    It does and you can even use the OCR API in a WPF or WinForms application: [OCR in WPF using the WinRT OCR API](https://www.codeproject.com/Articles/5276805/OCR-in-WPF-using-the-WinRT-OCR-API)

    "As beings of finite lifespan, our contributions to the sum of human knowledge is one of the greatest endeavors we can undertake and one of the defining characteristics of humanity itself"

    The Lounge csharp com help tutorial question

  • Binding To Single List Item
    M Meshack Musundi

    Quite true, I had taken note of that. I only supposed that the more apt approach would be to use a dependency property.

    "As beings of finite lifespan, our contributions to the sum of human knowledge is one of the greatest endeavors we can undertake and one of the defining characteristics of humanity itself"

    WPF wpf help database wcf question

  • Binding To Single List Item
    M Meshack Musundi

    Something like this, Code behind

    public partial class SomeControl : UserControl
    {
    public SomeControl()
    {
    InitializeComponent();
    for (int i = 0; i < 20; i++)
    {
    OnOffValues.Add(true);
    }
    }

    public List<bool> OnOffValues
    {
        get { return (List<bool>)GetValue(OnOffValuesProperty); }
        set { SetValue(OnOffValuesProperty, value); }
    }
    
    public static readonly DependencyProperty OnOffValuesProperty =
        DependencyProperty.Register("OnOffValues", typeof(List<bool>),
            typeof(SomeControl), new PropertyMetadata(new List<bool>()));
    

    }

    XAML

    <CheckBox IsChecked="{Binding Path=OnOffValues[0], RelativeSource={RelativeSource FindAncestor, AncestorType=UserControl}}"/>

    "As beings of finite lifespan, our contributions to the sum of human knowledge is one of the greatest endeavors we can undertake and one of the defining characteristics of humanity itself"

    WPF wpf help database wcf question

  • Binding To Single List Item
    M Meshack Musundi

    Look at his binding, IsChecked="{Binding OnOffValues[0], ElementName=control}" and the property, OnOffValues, is in the code behind of his user control. If he changes the property to a dependency property he won't get the error.

    "As beings of finite lifespan, our contributions to the sum of human knowledge is one of the greatest endeavors we can undertake and one of the defining characteristics of humanity itself"

    WPF wpf help database wcf question

  • Binding To Single List Item
    M Meshack Musundi

    Your binding assumes that OnOffValues is a dependency property of the control.

    "As beings of finite lifespan, our contributions to the sum of human knowledge is one of the greatest endeavors we can undertake and one of the defining characteristics of humanity itself"

    WPF wpf help database wcf question

  • Desktop: WinForms, WPF, UWA
    M Meshack Musundi

    raddevus wrote:

    I was looking for a way to make sure my UWA (XAML-based) app's ListView would show the last selected item even when it lost focus

    I'm not well versed in UWA matters but in WPF using a behavior would be one route you could take. Maybe not exactly what you're trying to achieve, but when working on a SignalR-WPF chat application I needed new items added to an ItemsControl to scroll into view, which is not the default behavior of the ItemsControl. I wrote a behavior to achieve this, which you can look at here: [SignalChat: WPF & SignalR Chat Application](https://www.codeproject.com/Articles/1181555/SignalChat-WPF-SignalR-Chat-Application).

    "As beings of finite lifespan, our contributions to the sum of human knowledge is one of the greatest endeavors we can undertake and one of the defining characteristics of humanity itself"

    The Lounge csharp wpf learning winforms com

  • Generate a WPF-Menu based on a XML-document
    M Meshack Musundi

    Deserialize the XML document to a collection of say Menu objects. Then do the necessary binding to reflect what you want in the view.

    "As beings of finite lifespan, our contributions to the sum of human knowledge is one of the greatest endeavors we can undertake and one of the defining characteristics of humanity itself"

    C# csharp wpf xml help

  • Rx - Reactive Extensions
    M Meshack Musundi

    I would recommend starting off [here](https://msdn.microsoft.com/en-us/library/dd990377.aspx) before delving into the Rx book.

    "As beings of finite lifespan, our contributions to the sum of human knowledge is one of the greatest endeavors we can undertake and one of the defining characteristics of humanity itself"

    C# html com help tutorial question

  • Retrieving value from an XML file
    M Meshack Musundi

    You can get and set the value using LINQ to XML and XML axis properties.

    Dim conceptor = XDocument.Load("C:\file.xml")
    ' Retrieve value
    Dim subjectField = conceptor...<descrip>.Where(Function(d) d.@type = "subjectField").Value
    ' Change value
    conceptor...<descrip>.Where(Function(d) d.@type = "subjectField").Value = "1234"
    ' Save changes
    conceptor.Save("C:\file.xml")

    The descendant axis property, ...<>, gets all descendants that have the name specified within the angle brackets. The attribute axis property, .@, returns a reference to the value of the specified attribute. The Value axis property returns a reference to the value of the first element in a collection of elements.

    "As beings of finite lifespan, our contributions to the sum of human knowledge is one of the greatest endeavors we can undertake and one of the defining characteristics of humanity itself"

    Visual Basic csharp xml help

  • Embedded YouTube video does not show up after publishing article
    M Meshack Musundi

    It's a site bug.

    "As beings of finite lifespan, our contributions to the sum of human knowledge is one of the greatest endeavors we can undertake and one of the defining characteristics of humanity itself"

    Site Bugs / Suggestions csharp wpf com hardware lounge

  • Embedded YouTube video does not show up after publishing article
    M Meshack Musundi

    The embedded YouTube video shows up when I preview the article but not after publishing: [SignalChat: WPF & SignalR Chat Application](https://www.codeproject.com/Articles/1181555/SignalChat-WPF-SignalR-Chat-Application) The iframe is changed to a div after publishing.

    "As beings of finite lifespan, our contributions to the sum of human knowledge is one of the greatest endeavors we can undertake and one of the defining characteristics of humanity itself"

    Site Bugs / Suggestions csharp wpf com hardware lounge

  • Embedding YouTube video in article
    M Meshack Musundi

    Hi Daniel, how did you manage to resolve this issue?

    "As beings of finite lifespan, our contributions to the sum of human knowledge is one of the greatest endeavors we can undertake and one of the defining characteristics of humanity itself"

    Site Bugs / Suggestions question csharp com architecture

  • Embedding YouTube video in article
    M Meshack Musundi

    Hi Chris. I'm experiencing this issue. Video was showing up in preview but isn't showing after publishing: [SignalChat: WPF & SignalR Chat Application](https://www.codeproject.com/Articles/1181555/SignalChat-WPF-SignalR-Chat-Application)

    "As beings of finite lifespan, our contributions to the sum of human knowledge is one of the greatest endeavors we can undertake and one of the defining characteristics of humanity itself"

    Site Bugs / Suggestions question csharp com architecture

  • WPF/MVVM - How To Make A Chess Board
    M Meshack Musundi

    Kevin Marois wrote:

    What's the best way to make a Chess board using WPF and MVVM?

    I asked myself the same question before working on StockChess[^] and I'm guessing you've figured out by now that the approach you've mentioned will not get you the result you want. If you want it to be MVVM friendly you will just have to create an items control that uses a Grid for its ItemsPanelTemplate. If you use an items control that enables you to select an item then even better, like a ListBox.

    "As beings of finite lifespan, our contributions to the sum of human knowledge is one of the greatest endeavors we can undertake and one of the defining characteristics of humanity itself"

    WPF wpf csharp css wcf architecture

  • UserControl
    M Meshack Musundi

    Kevin Marois wrote:

    How do you reverse the board for the other player?

    By reverse I guess you mean flip. I rotate the ListBox and switch its DataTemplate. One DataTemplate has the Image control rotated at an angle of 0 while the other has the Image control rotated at an angle of 180 degrees.

    "As beings of finite lifespan, our contributions to the sum of human knowledge is one of the greatest endeavors we can undertake and one of the defining characteristics of humanity itself"

    WPF csharp css wpf winforms design

  • UserControl
    M Meshack Musundi

    In a chess app I wrote some time back: WPF: P2P Chess[^], I took an approach similar to what you're doing. I had a bunch of user controls to represent the pieces. Over time I grew uncomfortable with this and decided to take an MVVM friendly approach for an app I'm currently developing, where the user plays against Stockfish. The chess board in my current app is a ListBox whose ItemsPanel is a Grid with eight row and eight columns. The ItemsSource property of the ListBox is bound to a collection of objects that implement the same interface. The collection, in the View Model, is made up of BoardSquares and ChessPieces. The DataTemplate of the ListBox is an Image that uses MultiDataTriggers to determine the appropriate image to display depending on the type of object. I'll be posting an article soon, maybe tommorrow, where you can dig deeper into the code.

    "As beings of finite lifespan, our contributions to the sum of human knowledge is one of the greatest endeavors we can undertake and one of the defining characteristics of humanity itself"

    WPF csharp css wpf winforms design

  • DP not Working
    M Meshack Musundi

    It should be,

    <TextBlock Text="{Binding DayNameCaption, RelativeSource={RelativeSource FindAncestor, AncestorType={UserControl}}}"... />

    You don't need the callback.

    "As beings of finite lifespan, our contributions to the sum of human knowledge is one of the greatest endeavors we can undertake and one of the defining characteristics of humanity itself"

    WPF help tutorial

  • Binding the x,y location on a Canvas with a ItemsControl
    M Meshack Musundi

    My answer was in response to Pete's question.

    "As beings of finite lifespan, our contributions to the sum of human knowledge is one of the greatest endeavors we can undertake and one of the defining characteristics of humanity itself"

    WPF wpf wcf question

  • Binding the x,y location on a Canvas with a ItemsControl
    M Meshack Musundi

    You might set the name of the user control to something different when its an element in your window. Setting the name property in the user control will still work though since it is initialized before the containing window. Using Binding.RelativeSource is a suitable option.

    "As beings of finite lifespan, our contributions to the sum of human knowledge is one of the greatest endeavors we can undertake and one of the defining characteristics of humanity itself"

    WPF wpf wcf question

  • Passing two parameters in Command biding in WPF and MVVM
    M Meshack Musundi

    Your binding mode should be OneWayToSource not OneWay,

    <TextBox Text="{Binding Name, Mode=OneWayToSource}" HorizontalAlignment="Left" Height="22" Margin="160,64,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="120"/>

    Or TwoWay if you want your View and the property in your ViewModel to modify each other.

    "As beings of finite lifespan, our contributions to the sum of human knowledge is one of the greatest endeavors we can undertake and one of the defining characteristics of humanity itself"

    WPF question wpf csharp architecture help
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups