Con Float converter en el PropertyGrid
This commit is contained in:
parent
47735ef00a
commit
a1ecfca034
|
@ -7,6 +7,7 @@
|
||||||
xmlns:local="clr-namespace:CtrEditor"
|
xmlns:local="clr-namespace:CtrEditor"
|
||||||
xmlns:uc="clr-namespace:CtrEditor.ObjetosSim.UserControls"
|
xmlns:uc="clr-namespace:CtrEditor.ObjetosSim.UserControls"
|
||||||
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
|
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
|
||||||
|
xmlns:sys="clr-namespace:System;assembly=mscorlib"
|
||||||
xmlns:ObjetosSim="clr-namespace:CtrEditor.ObjetosSim" x:Class="CtrEditor.MainWindow"
|
xmlns:ObjetosSim="clr-namespace:CtrEditor.ObjetosSim" x:Class="CtrEditor.MainWindow"
|
||||||
Height="900" Width="1600" WindowState="Maximized"
|
Height="900" Width="1600" WindowState="Maximized"
|
||||||
ResizeMode="CanResize" Title="{Binding directorioTrabajo}" Icon="/app2.png">
|
ResizeMode="CanResize" Title="{Binding directorioTrabajo}" Icon="/app2.png">
|
||||||
|
@ -164,7 +165,21 @@
|
||||||
VerticalAlignment="Center"/>
|
VerticalAlignment="Center"/>
|
||||||
|
|
||||||
<!-- PanelEdicion -->
|
<!-- PanelEdicion -->
|
||||||
<xctk:PropertyGrid Grid.Row="2" Margin="5" Name="PanelEdicion" AutoGenerateProperties="False">
|
<xctk:PropertyGrid Grid.Row="2" Margin="5" x:Name="PanelEdicion" AutoGenerateProperties="False" SelectedObject="{Binding}">
|
||||||
|
|
||||||
|
<xctk:PropertyGrid.EditorDefinitions>
|
||||||
|
<xctk:EditorTemplateDefinition>
|
||||||
|
<xctk:EditorTemplateDefinition.TargetProperties>
|
||||||
|
<xctk:TargetPropertyType Type="{x:Type sys:Single}" />
|
||||||
|
</xctk:EditorTemplateDefinition.TargetProperties>
|
||||||
|
<xctk:EditorTemplateDefinition.EditingTemplate>
|
||||||
|
<DataTemplate>
|
||||||
|
<TextBox Text="{Binding Value, Converter={StaticResource floatFormatter}}"/>
|
||||||
|
</DataTemplate>
|
||||||
|
</xctk:EditorTemplateDefinition.EditingTemplate>
|
||||||
|
</xctk:EditorTemplateDefinition>
|
||||||
|
</xctk:PropertyGrid.EditorDefinitions>
|
||||||
|
|
||||||
</xctk:PropertyGrid>
|
</xctk:PropertyGrid>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -94,6 +94,37 @@ namespace CtrEditor.ObjetosSim
|
||||||
.Cast<PropertyDescriptor>()
|
.Cast<PropertyDescriptor>()
|
||||||
.Where(prop => !prop.Attributes.OfType<HiddenAttribute>().Any());
|
.Where(prop => !prop.Attributes.OfType<HiddenAttribute>().Any());
|
||||||
|
|
||||||
|
|
||||||
|
//// Create the DataTemplate for float and double editors
|
||||||
|
//var doubleFactory = new FrameworkElementFactory(typeof(DoubleUpDown));
|
||||||
|
//doubleFactory.SetValue(DoubleUpDown.FormatStringProperty, "F3");
|
||||||
|
//doubleFactory.SetValue(DoubleUpDown.IncrementProperty, 0.001);
|
||||||
|
//doubleFactory.SetValue(DoubleUpDown.MaximumProperty, 200000.599);
|
||||||
|
//doubleFactory.SetBinding(DoubleUpDown.ValueProperty, new Binding("Value")
|
||||||
|
//{
|
||||||
|
// Mode = BindingMode.TwoWay,
|
||||||
|
// UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
|
||||||
|
//});
|
||||||
|
|
||||||
|
//var doubleTemplate = new DataTemplate { VisualTree = doubleFactory };
|
||||||
|
|
||||||
|
//// Add editor definitions for float and double
|
||||||
|
//var floatEditorDefinition = new EditorDefinition
|
||||||
|
//{
|
||||||
|
// EditorTemplate = doubleTemplate,
|
||||||
|
// TargetType = typeof(float)
|
||||||
|
//};
|
||||||
|
|
||||||
|
//var doubleEditorDefinition = new EditorDefinition
|
||||||
|
//{
|
||||||
|
// EditorTemplate = doubleTemplate,
|
||||||
|
// TargetType = typeof(double)
|
||||||
|
//};
|
||||||
|
|
||||||
|
//propertyGrid.EditorDefinitions.Add(floatEditorDefinition);
|
||||||
|
//propertyGrid.EditorDefinitions.Add(doubleEditorDefinition);
|
||||||
|
|
||||||
|
|
||||||
foreach (var property in properties)
|
foreach (var property in properties)
|
||||||
{
|
{
|
||||||
var displayNameAttr = property.Attributes.OfType<DisplayNameAttribute>().FirstOrDefault();
|
var displayNameAttr = property.Attributes.OfType<DisplayNameAttribute>().FirstOrDefault();
|
||||||
|
@ -117,35 +148,6 @@ namespace CtrEditor.ObjetosSim
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the DataTemplate for float and double editors
|
|
||||||
var doubleFactory = new FrameworkElementFactory(typeof(DoubleUpDown));
|
|
||||||
doubleFactory.SetValue(DoubleUpDown.FormatStringProperty, "F3");
|
|
||||||
doubleFactory.SetValue(DoubleUpDown.IncrementProperty, 0.001);
|
|
||||||
doubleFactory.SetValue(DoubleUpDown.MaximumProperty, 200000.599);
|
|
||||||
doubleFactory.SetBinding(DoubleUpDown.ValueProperty, new Binding("Value")
|
|
||||||
{
|
|
||||||
Mode = BindingMode.TwoWay,
|
|
||||||
UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
|
|
||||||
});
|
|
||||||
|
|
||||||
var doubleTemplate = new DataTemplate { VisualTree = doubleFactory };
|
|
||||||
|
|
||||||
// Add editor definitions for float and double
|
|
||||||
var floatEditorDefinition = new EditorDefinition
|
|
||||||
{
|
|
||||||
EditorTemplate = doubleTemplate,
|
|
||||||
TargetType = typeof(float)
|
|
||||||
};
|
|
||||||
|
|
||||||
var doubleEditorDefinition = new EditorDefinition
|
|
||||||
{
|
|
||||||
EditorTemplate = doubleTemplate,
|
|
||||||
TargetType = typeof(double)
|
|
||||||
};
|
|
||||||
|
|
||||||
propertyGrid.EditorDefinitions.Add(floatEditorDefinition);
|
|
||||||
propertyGrid.EditorDefinitions.Add(doubleEditorDefinition);
|
|
||||||
|
|
||||||
propertyGrid.SelectedObject = selectedObject;
|
propertyGrid.SelectedObject = selectedObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue