<!-- Define the style for component item headers -->
<
DataTemplate
x:Key
=
"PaneHeaderTemplate"
>
<
StackPanel
Orientation
=
"Horizontal"
VerticalAlignment
=
"Center"
>
<
TextBlock
Text
=
"{Binding ComponentDisplayName}"
/>
<
Button
Command
=
"{Binding CloseComponentCommand}"
Style
=
"{StaticResource ReportButtonStyle}"
Margin
=
"10,0,0,0"
ToolTipService.ToolTip
=
"Remove Component"
>
<
Button.Content
>
<
Path
Data
=
"M0,0 L6,6 M6, 0 L0,6"
Stroke
=
"Black"
StrokeThickness
=
"1"
SnapsToDevicePixels
=
"True"
/>
</
Button.Content
>
</
Button
>
</
StackPanel
>
</
DataTemplate
>
private void btnDelete_Click(object sender, RoutedEventArgs e)
{
try
{
var selcontainer = treeColumns.SelectedContainer;
WorkFlow selitem = treeColumns.SelectedItem as WorkFlow;
_collection.Remove(selitem);
}
}
I also handled the CollectedChanged event:
void _collection_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
{
try
{
if (e.Action == NotifyCollectionChangedAction.Remove)
{
foreach (object geoobject in e.OldItems)
{
ctx.WorkFlows.DeleteObject((WorkFlow)geoobject);
}
}
ctx.SaveChanges();
}
catch (Exception ex)
{
Helper.SetError(ex);
}
}
<Window x:Class=
"WpfApplication7.MainWindow"
Title=
"MainWindow"
Height=
"350"
Width=
"525"
xmlns:telerik=
"http://schemas.telerik.com/2008/xaml/presentation"
>
<Window.Resources>
<XmlDataProvider x:Key=
"XmlData"
Source=
"CountryList.xml"
XPath=
"CountryList"
/>
</Window.Resources>
<Grid>
<telerik:RadComboBox Height=
"23"
ItemsSource=
"{Binding Source={StaticResource XmlData}, XPath=./CountryName}"
DisplayMemberPath=
"@Name"
HorizontalAlignment=
"Left"
Margin=
"176,88,0,0"
Name=
"comboBox1"
VerticalAlignment=
"Top"
Width=
"156"
IsEditable=
"True"
/>
</Grid>
</Window>
and This
is
my countrylist Xml file.
<?xml version=
"1.0"
encoding=
"utf-8"
?>
<CountryList>
<CountryName Name=
"Afghanistan"
/>
<CountryName Name=
"Akrotiri"
/>
<CountryName Name=
"Albania"
/>
<CountryName Name=
"Algeria"
/>
<CountryName Name=
"American Samoa"
/>
<CountryName Name=
"Andorra"
/>
<CountryName Name=
"Angola"
/>
<CountryName Name=
"Anguilla"
/>
<CountryName Name=
"Mauritius"
/>
<CountryName Name=
"Mayotte"
/>
<CountryName Name=
"Mexico"
/>
<CountryName Name=
"Micronesia"
/>
<CountryName Name=
"Moldova"
/>
<CountryName Name=
"Monaco"
/>
<CountryName Name=
"Mongolia"
/>
<CountryName Name=
"Montserrat"
/>
<CountryName Name=
"Morocco"
/>
<CountryName Name=
"Western Sahara"
/>
<CountryName Name=
"Yemen"
/>
<CountryName Name=
"Zambia"
/>
<CountryName Name=
"Zimbabwe"
/>
</CountryList>
<
StackPanel
Margin
=
"8,4"
>
<
TextBlock
Text
=
"Description:"
FontWeight
=
"Bold"
/>
<
TextBlock
Text
=
"{Binding Description}"
FontStyle
=
"Italic"
TextWrapping
=
"WrapWithOverflow"
/>
</
StackPanel
>