We're using the WPF version, and see where we can set the width and cell width of the xamcomboboxeditor control to a numeric value. Is it possible to set it to "Auto", so the column resizes automatically?
Hello Rick,
Instead of setting the CellWidth and the LabelWidth properties of the FieldSettings for a given Field, I can suggest setting the Width property of the Field itself. If can be set to “Auto” in order to take the needed with, so the content of all cells will be visible. You can read more detailed information regarding the With property of the Field here in our online documentation: http://help.infragistics.com/NetAdvantage/WPF/2011.1/CLR4.0/?page=InfragisticsWPF4.DataPresenter.v11.1~Infragistics.Windows.DataPresenter.Field~Width.html
If you have any further question on the matter please do not hesitate to ask.
Sincerely,
Krasimir
Developer Support Engineer
Infragistics
www.infragistics.com/support
Not an answer yet, we're having an issue. I'm working up an example now.
Thank you for your efforts.
I will be waiting for the sample and I will do my best to investigate it further for you.
I'm going to just have to explain the problem. So we made custom controls inherited from DataPresenter.Field in order to have standard styled controls. For example, we made a combobox control. We want to autosize the combobox with these properties:
this.Settings.AutoSizeOptions = FieldAutoSizeOptions.All; this.Settings.AutoSizeScope = FieldAutoSizeScope.ViewableRecords; this.Settings.Width = new FieldLength(50,FieldLengthUnitType.InitialAuto);
The 50 in the FieldLength property has always been kinda quirky, but it works ok. Well, it works for everything except the situation where we use a multibinding to display more than one value in the drop down.
So we put the xaml on the usercontrol like this:
<Grid:ComboBoxField Label="My Combo Box" Name="MyComboBoxName" DisplayMemberPath="MyDisplayPath" ItemSourcePath="MySourcePath" ItemTemplate="{StaticResource MyTemplate}"/>
and in the resources section we define this style:
<DataTemplate x:Key="MyTemplate"> <TextBlock> <TextBlock.Text> <MultiBinding StringFormat="{}{0} - {1}"> <Binding Path="Part1Path" /> <Binding Path="Part2Path" /> </MultiBinding> </TextBlock.Text> </TextBlock></DataTemplate>
Whenever we do this, the comboboxes stretch to about 4 or 5 times what their actual size should be. How do I fix this so the multibindings work properly?
I have been looking into your last post and I can suggest replacing the StringFormat in the MultiBinding of the TextBlock with MultiValueConverter like :
<Window.Resources>
<local:MyConverter x:Key="sumConverter"/>
</Window.Resources>
<MultiBinding Converter="{StaticResource sumConverter}" >
...
</MultiBinding>
The MultiValueConverter can look like :
class MyConverter : IMultiValueConverter
{
public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
string total = null;
foreach (string val in values)
total += " " + val;
return total;
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
throw new NotImplementedException();
Would you please check whether the value of the total variable which the Converter returns as a result contains unwished empty spaces which make the field extends.
If this does not meet your scenario would you please provide me a small, isolated sample that represents your issue.
I am looking forward to hearing from you.
That was a better format for the drop down, but the column still does not auto size properly. Is it something to do with the cellpresenterstyle or cellvaluepresenterstyle?
I have been looking into your last post and according to your description I assume that your issue with the auto sizing of the column might occur because of the re-templating the CellPresenter or the CellValuePresenter. I can suggest using the default styles when re-templating those elements, in order to keep their original functionality. You can find the default styles for the CellValuePresenter and CellPresenter in the following file :
C:\Program Files (x86)\Infragistics\NetAdvantage 2011.2\WPF\DefaultStyles\DataPresenter\DataPresenterGeneric_Express.xaml
I can also suggest changing the FieldLengthUnitType from InitialAuto to Auto. By setting the Width of the Field to Auto, the Field will change every time when we change the value of a cell of this field. For more information about FieldAutoSizeOption you can look through the following link :
http://help.infragistics.com/NetAdvantage/WPF/2011.2/CLR4.0/?page=InfragisticsWPF4.DataPresenter.v11.2~Infragistics.Windows.DataPresenter.FieldLengthUnitType.html
Please inform me whether this solves your issue and if not please provide me with a simple working sample that represents your issue.