Here is what is working
In code
this.lb.ItemsSource = dds.Data;
IN xaml
<ListBox Name="lb" Height="629">
<
ListBox.ItemTemplate
>
<
DataTemplate
>
<
TextBox
Text
=
"{Binding LongDescription}"
TextWrapping
=
"Wrap"
Height
=
"600"
Width
=
"800"
/>
</
DataTemplate
>
</
ListBox.ItemTemplate
>
</
ListBox
>
I have tried
this
.lb.HtmlSource =
but I cannot figure out how to address the actual field LongDescription as opposed to the entire dds.Data
Is there a way to bind it in XAML or code?
Should I be using a different control?
6 Answers, 1 is accepted
Someone must know how to bind either the RadRichTextBox or the HTMLPlaceHolder to a data source with an HTML string.
I prepared a sample project illustrating how to implement the desired scenario using a RadHtmlPlaceHolder and a RadRichTextBox. Please take a look at it and let me know if it works for you.
Kind regards,
Tina Stancheva
the Telerik team
Code: 4004
Category: ParserError
Message: The invocation of the constructor on type 'Telerik.Windows.Controls.RadHtmlPlaceholder' that matches the specified binding constraints threw an exception.
File:
Line: 25
Position: 56
I took your code
code behind
storeDomainContext ctx =
new
storeDomainContext();
dds.QueryName =
"GetProductDetailsQuery"
;
dds.DomainContext = ctx;
dds.AutoLoad =
true
;
filterPD.PropertyPath =
"ProdID"
;
filterPD.Operator = FilterOperator.IsEqualTo;
filterPD.Value =pvalue;
dds.FilterDescriptors.Add(filterPD);
this
.lb.ItemsSource = dds.Data;
try
{
dds.Load();
}
catch
{
}
XAML
<ListBox Name=
"lb"
Height=
"629"
>
<ListBox.ItemTemplate>
<DataTemplate>
<telerik:RadHtmlPlaceholder Height=
"600"
Width=
"800"
HtmlSource=
"{Binding LongDescription}"
/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
what does this error tell you?
I cannot be entirely sure what is causing this issue, however such exceptions might be raised if the Silverlight plug-in isn't in a windowless mode. It is important to note that the Silverlight plug-in that hosts the RadHtmlPlaceHolder control has to be Windowless enabled. For example if the Silverlight application is hosted in an html page, then:
<
div
id
=
"silverlightControlHost"
>
<
object
data
=
"data:application/x-silverlight-2,"
type
=
"application/x-silverlight-2"
width
=
"100%"
height
=
"100%"
>
<
param
name
=
"source"
value
=
"ClientBin/RadHtmlPlachoderDemo.xap"
/>
<
param
name
=
"onerror"
value
=
"onSilverlightError"
/>
<
param
name
=
"background"
value
=
"white"
/>
<
param
name
=
"minRuntimeVersion"
value
=
"2.0.31005.0"
/>
<
param
name
=
"autoUpgrade"
value
=
"true"
/>
<
param
name
=
"windowless"
value
=
"true"
/>
<
a
href
=
"http://go.microsoft.com/fwlink/?LinkID=124807"
style
=
"text-decoration: none;"
>
<
img
src
=
"http://go.microsoft.com/fwlink/?LinkId=108181"
alt
=
"Get Microsoft Silverlight"
style
=
"border-style: none"
/>
</
a
>
</
object
>
<
iframe
style
=
'visibility:hidden;height:0;width:0;border:0px'
></
iframe
>
</
div
>
Also, since the default ItemsPanel of the ListBox is the VirtualizingStackPanel, this might also be a cause for exceptions with the RadHtmlPlaceHolder, so in your scenario I would recommend changing the default ItemsPanel of the ListBox:
<
ListBox
Name
=
"lb"
>
<
ListBox.ItemsPanel
>
<
ItemsPanelTemplate
>
<
StackPanel
/>
</
ItemsPanelTemplate
>
</
ListBox.ItemsPanel
>
<
ListBox.ItemTemplate
>
<
DataTemplate
>
<
telerik:RadHtmlPlaceholder
Height
=
"600"
Width
=
"800"
HtmlSource
=
"{Binding Text}"
/>
</
DataTemplate
>
</
ListBox.ItemTemplate
>
</
ListBox
>
I hope this info helps. Please give it a try and let me know if it works for you.
Greetings,
Tina Stancheva
the Telerik team
I need something like this;
I am adding RadRibbonDropDownButton to radRibbon.
Than I am adding ListBox to the RadRibbonDropDownButton .
Here is the code in View.
private void AddItemsToRibbon
{
_HeaderFooterBindingButton = new RadRibbonDropDownButton()
{
Text ="Header/Footer Binding",
Size = ButtonSize.Large
};
_HeaderFooterBindingListBox = new ListBox()
{
VerticalContentAlignment = System.Windows.VerticalAlignment.Center,
HorizontalContentAlignment = HorizontalAlignment.Left,
Width = 150,
Height = 75,
};
var sv = new ScrollViewer() { Height = 100, Content = _HeaderFooterBindingListBox };
var stackPanel = new StackPanel() { Orientation = System.Windows.Controls.Orientation.Vertical };
stackPanel.Children.Add(sv);
var customMenuItem = new RadMenuItem() { Header = "New..." };
stackPanel.Children.Add(customMenuItem);
_PageLayoutGroup.Items.Add(_HeaderFooterBindingButton);
AddHeaderFooterTemplateBindings();
_HeaderFooterBindingButton.DropDownContent = stackPanel;
}
private void AddHeaderFooterTemplateBindings()
{
var binding = new Binding();
binding.Mode = BindingMode.OneWay;
binding.Path = new PropertyPath("Templates");
_HeaderFooterBindingListBox.SetBinding(ItemsSourceProperty, binding);
var binding1 = new Binding();
binding1.Mode = BindingMode.TwoWay;
binding1.Path = new PropertyPath("SelectedTemplate");
_HeaderFooterBindingListBox.SetBinding(Selector.SelectedItemProperty, binding1);
}
the list box is loaded with the data but I am not able to select or mouse over or click the item in the list box..
Also SelectedItemProperty binding property is not working at all.
If I put RadRibbonComboBox directly on Ribbon than it works fine.
Any help will be appreciated.
Thanks,
Laxman
Since we were having many issues with our Telerik.Windows.Controls.ListBox, we announced it as an obsolete control. We highly recommend you to use System.Windows.Controls.ListBox like it is done in the attached sample. Please give it a try and let us know how it goes.
All the best,
Petar Mladenov
the Telerik team