Click here to Skip to main content
15,891,184 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: MVVM: Transfering data from ViewModel to Model, when and how ? Pin
_Maxxx_21-Jul-11 13:55
professional_Maxxx_21-Jul-11 13:55 
GeneralRe: MVVM: Transfering data from ViewModel to Model, when and how ? Pin
BubingaMan25-Jul-11 1:46
BubingaMan25-Jul-11 1:46 
AnswerRe: MVVM: Transfering data from ViewModel to Model, when and how ? Pin
RobCroll20-Jul-11 1:53
RobCroll20-Jul-11 1:53 
AnswerRe: MVVM: Transfering data from ViewModel to Model, when and how ? Pin
_Maxxx_21-Jul-11 14:06
professional_Maxxx_21-Jul-11 14:06 
QuestionDynamically changing themes from DLL at run-time Pin
Prasoon Chaudhary19-Jul-11 1:20
Prasoon Chaudhary19-Jul-11 1:20 
AnswerRe: Dynamically changing themes from DLL at run-time Pin
Varsha Ramnani20-Jul-11 21:23
professionalVarsha Ramnani20-Jul-11 21:23 
GeneralRe: Dynamically changing themes from DLL at run-time Pin
Prasoon Chaudhary20-Jul-11 22:42
Prasoon Chaudhary20-Jul-11 22:42 
QuestionFind an empty element in a Silverlight Grid Pin
Neo1010119-Jul-11 0:31
Neo1010119-Jul-11 0:31 
Well, I have been trying to figure this one out for three days straight and I still haven't come up with a fix.

Basically I am trying to swap out the clicked Ellipse with the only empty spot on the 3x3 checkerboard. 8 of the 9 squares are occupied. I need to find the one spot that is not occupied and I can't seem to do it. Why? Because even though there is an empty spot on the grid at runtime, Javascript refuses to acknowledge this. I used the line: var childrenCount = canvasArray[i].children.count; .. so that's all the canvases. If at runtime there is an empty spot, then how come my code refuses to see it? Or am I not writing the right code? How is the empty spot represented and found at runtime? That's what I want to know.

Here is the pseudocode:

if (squareOnGrid is empty) {
log.write(squareOnGrid + ' is empty');
emptySquare = squareOnGrid;

oldPositionBorder = sender;
oldPositionR = checkerPiece.row;
oldPositionC = checkerPiece.col;

checkerPiece.row = empty.row;
checkerPiece.column = squareOnGrid.column;

oldPositionBorder = null;
}

I want to do this with Javascript (not C#).

I already have this (Javascript):

<br />
function switchPlaces(sender) {<br />
<br />
    for (var i = 0; i < canvasArray.length; i++) {<br />
        var oldLocationBorderParent = sender;<br />
        var oldLocationCanvasParent = oldLocationBorderParent.findName('canvas' + (i + 1));<br />
        var oldLocationChild = oldLocationCanvasParent.findName('ellipse' + (i + 1));<br />
<br />
        var childrenCount = canvasArray[i].children.count;<br />
        log.info(childrenCount); //all of this outputs '1'. It should have a '0' in there, but no.<br />
<br />
        if (childrenCount == 0) {<br />
            log.info(canvasArray[i] + ' has no children');<br />
            var emptySpot = canvasArray[i];<br />
            sender['Grid.Row'] = emptySpot['Grid.Row'];<br />
            sender['Grid.Column'] = emptySpot['Grid.Column'];<br />
            oldLocationCanvasParent.children.remove(oldLocationChild);<br />
        }<br />
    }<br />
}<br />


Here is my Silverlight code:

<br />
<Grid<br />
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"<br />
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"<br />
  Loaded="onLoaded" ShowGridLines="True" Background="CornflowerBlue"><br />
<br />
    <Grid.ColumnDefinitions><br />
        <ColumnDefinition Width="100"/><br />
        <ColumnDefinition Width="100"/><br />
        <ColumnDefinition Width="100"/><br />
        <ColumnDefinition/><br />
    </Grid.ColumnDefinitions><br />
<br />
    <Grid.RowDefinitions><br />
        <RowDefinition Height="100"/><br />
        <RowDefinition Height="100"/><br />
        <RowDefinition Height="100"/><br />
    </Grid.RowDefinitions><br />
<br />
    <Border Grid.Row="0" Grid.Column="0" x:Name="b1" MouseLeftButtonUp="switchPlaces" ><br />
        <Canvas x:Name="canvas1"><br />
            <Ellipse Width="100" Height="100" x:Name="ellipse1" Fill="Red" Visibility="Visible"/><br />
        </Canvas><br />
    </Border><br />
<br />
    <Border Grid.Column="0" Grid.Row="1" x:Name="b2" MouseLeftButtonUp="switchPlaces"  ><br />
        <Canvas x:Name="canvas2"><br />
            <Ellipse Width="100" Height="100" x:Name="ellipse2" Visibility="Visible"/><br />
        </Canvas><br />
    </Border><br />
<br />
    <Border Grid.Column="0" Grid.Row="2" x:Name="b3" MouseLeftButtonUp="switchPlaces"   ><br />
        <Canvas x:Name="canvas3"><br />
            <Ellipse Width="100" Height="100" x:Name="ellipse3" Visibility="Visible"/><br />
        </Canvas><br />
    </Border><br />
<br />
    <Border Grid.Column="1" Grid.Row="1" x:Name="b4" MouseLeftButtonUp="switchPlaces"   ><br />
        <Canvas x:Name="canvas4"><br />
            <Ellipse Width="100" Height="100" x:Name="ellipse4" Visibility="Visible"/><br />
        </Canvas><br />
    </Border><br />
<br />
    <Border Grid.Column="1" Grid.Row="2" x:Name="b5" MouseLeftButtonUp="switchPlaces"   ><br />
        <Canvas x:Name="canvas5"><br />
            <Ellipse Width="100" Height="100" x:Name="ellipse5" Visibility="Visible"/><br />
        </Canvas><br />
    </Border><br />
<br />
    <Border Grid.Column="2" Grid.Row="0" x:Name="b6" MouseLeftButtonUp="switchPlaces"   ><br />
        <Canvas x:Name="canvas6"><br />
            <Ellipse Width="100" Height="100" x:Name="ellipse6" Visibility="Visible"/><br />
        </Canvas><br />
    </Border><br />
<br />
    <Border Grid.Column="2" Grid.Row="1" x:Name="b7" MouseLeftButtonUp="switchPlaces"   ><br />
        <Canvas x:Name="canvas7"><br />
            <Ellipse Width="100" Height="100" x:Name="ellipse7" Visibility="Visible"/><br />
        </Canvas><br />
    </Border><br />
<br />
    <Border Grid.Column="2" Grid.Row="2" x:Name="b8" MouseLeftButtonUp="switchPlaces" ><br />
        <Canvas x:Name="canvas8"><br />
            <Ellipse Width="100" Height="100" x:Name="ellipse8" Visibility="Visible"/><br />
        </Canvas><br />
    </Border><br />
<br />
</Grid><br />


If anyone has any idea how to fix this..

Thank you
QuestionRe: Find an empty element in a Silverlight Grid Pin
Mark Salsbery19-Jul-11 12:35
Mark Salsbery19-Jul-11 12:35 
QuestionEntity Framework - Sorting Relationproperties Pin
Nicolai Schrade18-Jul-11 22:52
Nicolai Schrade18-Jul-11 22:52 
QuestionPerformance stymied by UIElement_CreateAutomationPeer Pin
Lee Reid16-Jul-11 14:01
Lee Reid16-Jul-11 14:01 
AnswerRe: Performance stymied by UIElement_CreateAutomationPeer [modified] Pin
SledgeHammer0118-Jul-11 10:20
SledgeHammer0118-Jul-11 10:20 
GeneralRe: Performance stymied by UIElement_CreateAutomationPeer Pin
Lee Reid18-Jul-11 16:40
Lee Reid18-Jul-11 16:40 
Questionwpf time picker control in vb.net Pin
prachi_sathep16-Jul-11 0:30
prachi_sathep16-Jul-11 0:30 
AnswerRe: wpf time picker control in vb.net Pin
Kim Breugelmans18-Jul-11 22:07
Kim Breugelmans18-Jul-11 22:07 
AnswerRe: wpf time picker control in vb.net Pin
Oludayo Alli16-Aug-11 2:29
Oludayo Alli16-Aug-11 2:29 
QuestionHow to enable wpf controls through data binding on a selected item from a combo box Pin
Member 297299215-Jul-11 4:20
Member 297299215-Jul-11 4:20 
AnswerRe: How to enable wpf controls through data binding on a selected item from a combo box [modified] Pin
Mark Salsbery15-Jul-11 6:11
Mark Salsbery15-Jul-11 6:11 
QuestionGame algorithm problem Pin
Neo1010115-Jul-11 4:05
Neo1010115-Jul-11 4:05 
AnswerRe: Game algorithm problem Pin
Mark Salsbery15-Jul-11 6:41
Mark Salsbery15-Jul-11 6:41 
AnswerRe: Game algorithm problem Pin
Abhinav S15-Jul-11 6:51
Abhinav S15-Jul-11 6:51 
GeneralRe: Game algorithm problem Pin
Neo1010119-Jul-11 0:02
Neo1010119-Jul-11 0:02 
GeneralRe: Game algorithm problem Pin
Pete O'Hanlon19-Jul-11 1:46
mvePete O'Hanlon19-Jul-11 1:46 
GeneralRe: Game algorithm problem Pin
Neo101017-Nov-11 0:25
Neo101017-Nov-11 0:25 
QuestionWCF Async Call random response Pin
NTheOne13-Jul-11 18:01
NTheOne13-Jul-11 18:01 

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.