Skip to content

Commit e9f8a45

Browse files
Fixed ComboBox in Create and Edit Geometries WinUI sample (#1576)
1 parent 829e924 commit e9f8a45

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

src/WinUI/ArcGIS.WinUI.Viewer/Samples/Geometry/CreateAndEditGeometries/CreateAndEditGeometries.xaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@
6565
Grid.ColumnSpan="2"
6666
HorizontalAlignment="Stretch"
6767
Background="White"
68-
DisplayMemberPath="Key"
6968
SelectionChanged="ToolComboBox_SelectionChanged"
7069
ToolTipService.ToolTip="Tools" />
7170
<Border Grid.Row="3"

src/WinUI/ArcGIS.WinUI.Viewer/Samples/Geometry/CreateAndEditGeometries/CreateAndEditGeometries.xaml.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ private void Initialize()
107107
MyMapView.GeometryEditor = _geometryEditor;
108108

109109
// Create vertex and freehand tools for the combo box.
110-
ToolComboBox.ItemsSource = _toolDictionary = new Dictionary<string, object>()
110+
_toolDictionary = new Dictionary<string, object>()
111111
{
112112
{ "Vertex Tool", new VertexTool() },
113113
{ "Reticle Vertex Tool", new ReticleVertexTool() },
@@ -118,6 +118,8 @@ private void Initialize()
118118
{ "Triangle Shape Tool", ShapeTool.Create(ShapeToolType.Triangle) }
119119
};
120120

121+
ToolComboBox.ItemsSource = _toolDictionary.Keys;
122+
121123
// Have the vertex tool selected by default.
122124
ToolComboBox.SelectedIndex = 0;
123125

@@ -196,7 +198,8 @@ private void PolygonButton_Click(object sender, RoutedEventArgs e)
196198
private void ToolComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
197199
{
198200
// Set the geometry editor tool based on the new selection.
199-
_geometryEditor.Tool = ((KeyValuePair<string, object>)ToolComboBox.SelectedItem).Value as GeometryEditorTool;
201+
GeometryEditorTool tool = _toolDictionary[ToolComboBox.SelectedItem.ToString()] as GeometryEditorTool;
202+
_geometryEditor.Tool = tool;
200203

201204
// Account for case when vertex tool is selected and geometry editor is started with a polyline or polygon geometry type.
202205
// Ensure point and multipoint buttons are only enabled when the selected tool is a vertex tool.

0 commit comments

Comments
 (0)