XAML
<ComboBox Height="23.338" x:Name="cboCustom" />
Code which runs when the combobox should be populate
cboCustom.Items.Clear()
For x As Integer = 0 To (_collection.count - 1)
cboCustom.Items.Add(_collection.node(x))
Next
The _collection.node() is class with several properties
And I would like to set the displayMembervalue of the WPF combobo to it's description property.
I've tried
cboCustom.DisplayMemberPath = "myitem.description"
and
cboCustom.DisplayMemberPath = "description"
With no luck.
cboCustom.SeletedItem.description (on select action) does however give me the expected value.
Just use "Description" on its own (assuming that's the name of the property you want to display). Also, make sure the casing is correct.
Related
Just starting to use VS2013. Have several projects that I am porting from older technology. This should be really simple, so I am sure I am missing something easy.
The combo box is used to build a record. There is an ID field and a Description field. Very simple. I am trying to show the Description (which is text), but save the ID (which is int).
DataSource = table1BindingSource
DisplayMember = Description
ValueMember = ID
Databinding.Text = table2BindingSource.field1
I have tried setting
Databinding.SelectedValue = ID
and
Databinding.SelectedItem = ID
It displays in the dropdown correctly. It displays in the field correctly, using the Description. But value must not be associated with the field correctly, because I cannot save or move to the next record. Looks like the Description is getting put in the field1, and as it is int, it is not accepting it.
What am I missing?
I got it. For text boxes, I had been assigning
DataBinding.Text = Table1.field
So, I was trying to assign for combo boxes
DataSource = Table1
DisplayMember = Table1.description
ValueMember - Table1.code
and
DataBinding.SelectedValue = Table1.code
DataBinding.Text = Table2.field
I finally removed the Text statement and assigned
DataBinding.SelectedValue = Table2.field
And it all worked as desired.
In my WPF app, I use OxyPlot. I bind my data to the PlotModel and all is working well.
I want to display the value of each column on the chart. Is it possible?
For reference, this example of BarSeries on site, I wish to show actual value of Apples of 2009, 2010 & 2011 respectively on each column. i.e. value of Value1 for the 2009Apples column, Value2 for 2010Apples and so on.
I looked up at the APIof the BarSeries (For WPF ColumnSeries used interchangeably).
Tutorials of Bar & other plots. But couldn't find such thing anywhere.
How do I achieve this?
Yes, just set the LabelFormatString property of your series.
var theSeries = new ColumnSeries();
theSeries.LabelFormatString = "{0:F2}"; // Example: 1.2311 will display like "1.23"
// Add your columns
theSeries.Items.Add(new ColumnItem(someValue);
// ...
There is also an optional property you can set called LabelPlacement. The default value is LabelPlacement.Outside:
theSeries.LabelPlacement = LabelPlacement.Middle;
I want to determine if my WPF application UI is ready for interaction. When I inspect properties of my WpfTopLevelSubitemTestObject, I can see a property called "Cursor" of type TestObject.
However, I couldn't find a way to get cursor type or state from this "Cursor" property. Its properties are not accessible (getProperties throws a WrappedException); non-value properties are empty; it has a "get_CursorType" method which returns another TestObject, which is also useless.
Any ideas?
RFT supports WPF applications and here is how you could get the cursor property( of a WPF text box recorded in RFT as textBox1text2() )
TestObject t = (TestObject) textBox1text2().getProperty("Cursor");
System.out.println("Cursor Property: " + t.invoke("ToString"));
The property "Cursor" actually is of type System.Windows.Input.Cursor for which there is no value manager.
For a sample application where I have set the text box to have Cursor as "Pen" if I run the above code I would get the ouput as :
Cursor Property: Pen
If no cursor is set then you would most likely get the cursor property as NULL so it can add a NULL check before invoking ToString .
If you want to find out what is the actual type of object that the TestObject "t" is referring to you could also do this:
System.out.println("Actual Object type: "+ t.getObjectClassName() +". And Cursor: " + t.invoke("ToString"));
and output would be:
Actual Object type: System.Windows.Input.Cursor. And Cursor: Pen
Hope it helps.
When I set the Text property of RolesTextName from codebehind in a Silverlight5 app by doing:
RolesTextName.Text = "David & Goliath";
<TextBlock TextWrapping="Wrap">
<Span FontWeight="Bold">Roles:</Span>
<Span><Run x:Name="RolesTextName" /></Span>
</TextBlock>
Problem: I don't get the & symbol, just the actual text.
XAML is used to create an object graph that represents your user interface. When you modify the user interface by setting property values in code the XAML has already been processed and is no longer used. You should not do any XAML specific encoding when modifying the object graph from code. Encoding is only required in XAML because it is based on XML and you need a way to represents characters like &, < and > unambgiously.
So executing
RolesTextName.Text = "David & Goliath";
will set the text of the run to
David & Goliath
To achieve what you want simply execute this code insted:
RolesTextName.Text = "David & Goliath";
Hi im also quite new to XML, but I've had a similar problem in the past
This link gave me some insight, hope it can help you.
`<![CDATA[Wake & Bake]]>
http://www.w3schools.com/xmL/xml_cdata.asp
I'd like to use the built-in Silverlight 4.0 field validation on the following code, and am having trouble getting it to work.
MyForm.fs:
// imports, etc
type MyForm() as this =
inherit UriCanvasControl("/Project;component/MyForm.xaml", "Enter Stuff")
[<DefaultValue>]
val mutable myTextBox: TextBox
do
Application.LoadComponent(this, base.uri)
this.myTextBox <- this?myTextBox
// other stuff
MyForm.xaml:
// ...
<TextBox Name="myTextBox" Text="{Binding Path=myTextBox,Mode=TwoWay,ValidatesOnExceptions=True,NotifyOnValidationError=True}" TextChanged="Duration_Changed" Grid.Column="0" Margin="0,0,2,0"></TextBox>
// ...
I've tried putting annotations above the myTextBox field in the .fs file, but the compiler complained about that (annotations like: [Required(ErrorMessage="enter something!")]).
Any ideas? Thanks.
I think you'll have better luck with a property, e.g.
type Yadda() = ...
let mutable backingField : TextBox = null
[<RequiredOrWhatever(blah)>]
member this.TheProperty with get() = backingField
and set(x) = backingField <- x
but I don't know Silverlight details well enough to verify it right now.