Hi,
I am working with a project there I am making a list with colours and some text.
To add text and colour codes it's working fine.
Here is the XAML code:
<ListView Grid.Row="0" Margin="5" Name="lvCustomStream" Width="Auto">
<ListView.View>
<GridView >
<GridViewColumn Header="Length" Width="90" DisplayMemberBinding="{Binding Length}" />
<GridViewColumn Header="Speed" Width="90" DisplayMemberBinding="{Binding Speed}" />
<GridViewColumn Header="Colour1" Width="90" DisplayMemberBinding="{Binding Colour1}" />
<GridViewColumn Header="Colour2" Width="90" DisplayMemberBinding="{Binding Colour2}" />
</GridView>
</ListView.View>
</ListView>
<Grid Grid.Row="2">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal" Grid.Row="2">
<Button x:Name="btCsSave" Width="40" Margin=" 5" Content="Save" Click="btCsSave_Click"/>
<Button x:Name="btnCsCancel" Width="40" Margin="5" Content="Cancel" Click="btnCsCancel_Click"/>
</StackPanel>
<StackPanel Orientation="Horizontal" Grid.Row="1">
<Label Margin="5,5,0,5" Width="Auto" Content="Length"/>
<TextBox x:Name="txtCsLength" Margin="0,5,5,5" Width="40"/>
<Label Margin="5,5,0,5" Width="Auto" Content="Speed"/>
<TextBox x:Name="txtCsSpeed" Margin="0,5,5,5" Grid.Row="1" Width="40"/>
<Label Margin="5,5,0,5" Width="Auto" Content="Colour1"/>
<Rectangle x:Name="rectCsColour1" Margin="0,5,5,5" Grid.Row="1" Width="25" MouseDown="txtCsColour1_MouseDown" Fill="#FFFBD904"/>
<Label Margin="5,5,0,5" Width="Auto" Content="Colour2"/>
<Rectangle x:Name="rectCsColour2" Margin="0,5,5,5" Grid.Row="1" Width="25" Fill="#FFF9F904" MouseDown="rectCsColour2_MouseDown"/>
</StackPanel>
</Grid>
The code behind:
private void btCsSave_Click(object sender, RoutedEventArgs e)
{
if (txtCsThreadLength.Text == "") return;
lvCustomStream.Items.Add(new CsItem(txtCsLength.Text.ToString(), txtCsSpeed.Text.ToString(), rectCsColour1.Fill.ToString(), rectCsColour1, rectCsColour2.Fill.ToString()));
}
What is missing is: when I click on the save button, I want to get the two rectangles too into the ListView after the two colour values, not just the two Colour-values, Speed and Length.
Thanks in advance
Vidor