Click here to Skip to main content
15,884,807 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: Bind To Static Property Pin
Kevin Marois13-Jan-17 8:31
professionalKevin Marois13-Jan-17 8:31 
QuestionWPF/MVVM - How To Make A Chess Board Pin
Kevin Marois20-Dec-16 6:13
professionalKevin Marois20-Dec-16 6:13 
AnswerRe: WPF/MVVM - How To Make A Chess Board Pin
Meshack Musundi26-Dec-16 19:26
professionalMeshack Musundi26-Dec-16 19:26 
QuestionMetroTabItem View Going out of Scope Pin
JPKI13-Dec-16 12:59
JPKI13-Dec-16 12:59 
AnswerRe: MetroTabItem View Going out of Scope Pin
Pete O'Hanlon13-Dec-16 20:50
mvePete O'Hanlon13-Dec-16 20:50 
GeneralRe: MetroTabItem View Going out of Scope Pin
JPKI13-Dec-16 22:14
JPKI13-Dec-16 22:14 
GeneralRe: MetroTabItem View Going out of Scope Pin
JPKI15-Dec-16 8:33
JPKI15-Dec-16 8:33 
QuestionUserControl Pin
Kevin Marois5-Dec-16 11:02
professionalKevin Marois5-Dec-16 11:02 
I'm creating a chess game.

The board is made up of a grid of user controls called BoardSqaure:
<UserControl x:Class="Chess.UI.WPF.Controls.BoardSquare"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:local="clr-namespace:Chess.UI.WPF.Controls"
             mc:Ignorable="d" 
             d:DesignHeight="300" 
             d:DesignWidth="300">
    <ContentPresenter Content="{Binding Piece}"/>
</UserControl>
and
namespace Chess.UI.WPF.Controls
{
    public partial class BoardSquare : UserControl
    {
        public BoardSquare()
        {
            InitializeComponent();
        }

        public static readonly DependencyProperty PieceProperty =
                    DependencyProperty.Register("Piece",
                    typeof(PieceBase),
                    typeof(BoardSquare),
                    new PropertyMetadata(null));

        public PieceBase Piece
        {
            get { return (PieceBase)GetValue(PieceProperty); }
            set { SetValue(PieceProperty, value); }
        }
    }
}

The DP Piece will hold an instance of PieceBase, which can be King, Queen, Rook.. etc.

To load the board in the code behind I'm trying to do
private void SetupBoard()
{
    // Do this for the first 2 and last 2 rows for initial set up
    BoardSquare square = board.Children.Cast<BoardSquare>().First(e => Grid.GetRow(e) == 0 && Grid.GetColumn(e) == 0);
    square.Piece = new RookBlack();

    square = board.Children.Cast<BoardSquare>().First(e => Grid.GetRow(e) == 0 && Grid.GetColumn(e) == 1);
    square.Piece = new BishopBlack();

.
.
.

}

However the pieces never shows up.

What am I doing wrong here?
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.


modified 5-Dec-16 17:08pm.

AnswerRe: UserControl Pin
Jon McKee5-Dec-16 11:12
professionalJon McKee5-Dec-16 11:12 
GeneralRe: UserControl Pin
Kevin Marois5-Dec-16 11:22
professionalKevin Marois5-Dec-16 11:22 
GeneralRe: UserControl Pin
Jon McKee5-Dec-16 11:40
professionalJon McKee5-Dec-16 11:40 
GeneralRe: UserControl Pin
Kevin Marois5-Dec-16 11:46
professionalKevin Marois5-Dec-16 11:46 
GeneralRe: UserControl Pin
Jon McKee5-Dec-16 11:56
professionalJon McKee5-Dec-16 11:56 
AnswerRe: UserControl Pin
Gerry Schmitz5-Dec-16 11:29
mveGerry Schmitz5-Dec-16 11:29 
GeneralRe: UserControl Pin
Meshack Musundi5-Dec-16 22:23
professionalMeshack Musundi5-Dec-16 22:23 
GeneralRe: UserControl Pin
Kevin Marois6-Dec-16 4:49
professionalKevin Marois6-Dec-16 4:49 
GeneralRe: UserControl Pin
Meshack Musundi6-Dec-16 5:04
professionalMeshack Musundi6-Dec-16 5:04 
AnswerRe: UserControl Pin
Richard Deeming6-Dec-16 2:10
mveRichard Deeming6-Dec-16 2:10 
GeneralRe: UserControl Pin
Kevin Marois6-Dec-16 4:47
professionalKevin Marois6-Dec-16 4:47 
QuestionC# WPF listbox binding to selected item does not update my property Pin
Member 128805954-Dec-16 5:54
Member 128805954-Dec-16 5:54 
AnswerRe: C# WPF listbox binding to selected item does not update my property Pin
Richard Deeming5-Dec-16 1:58
mveRichard Deeming5-Dec-16 1:58 
GeneralRe: C# WPF listbox binding to selected item does not update my property Pin
Member 128805955-Dec-16 9:08
Member 128805955-Dec-16 9:08 
GeneralRe: C# WPF listbox binding to selected item does not update my property Pin
Jon McKee5-Dec-16 10:59
professionalJon McKee5-Dec-16 10:59 
GeneralRe: C# WPF listbox binding to selected item does not update my property Pin
Member 128805956-Dec-16 7:38
Member 128805956-Dec-16 7:38 
GeneralRe: C# WPF listbox binding to selected item does not update my property Pin
Jon McKee6-Dec-16 8:23
professionalJon McKee6-Dec-16 8:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.