|
Hi,
I am new to the silverlight world, is there any way to set the width of a TextBlock from code behind and call that method in the user controls Intialize method or in load even etc.
I am thinking in the way of asp.net only still, but there is lot of difference. Please help me yaar, I am in desperate need.
Thanks,
Abdul.
Thanks & Regards,
Abdul Aleem Mohammad
St Louis MO - USA
|
|
|
|
|
// C#
myTextBlock.Width = 10;
Mark Salsbery
|
|
|
|
|
Hi,
Thanks but that value should depend upon length of the string that comes from the View Model, is that possible.
Or accessing view model properties in code behind, is this possible anything is ok for me now.
Thanks in advance.
Thanks & Regards,
Abdul Aleem Mohammad
St Louis MO - USA
|
|
|
|
|
If you are trying to size to content, don't set the width manually and the control will auto-size. There is a lot more to auto-sizing then just the string length. What about font, font size, font style, fixed width vs. true type, etc?
EDIT: since you mentioned View Model, I assume you are using MVVM. The VM doesn't have access to the View unless you passed it in to the VM using various methods, but thats kind of defeating the whole point.
|
|
|
|
|
SledgeHammer01 wrote: don't set the width manually and the control will auto-size
Exactly this, only a canvas doesn't size automatically, but that control is rarely needed.
It is said that your life flashes before your eyes just before you die. That is true, it's called Life. - Terry Pratchett
|
|
|
|
|
You *could* (but probably shouldn't) use an IValueConverter. You'd bind to the string in the view model and use a converter that returns a width. If, however, you just want the textbox to autosize based on its content, there are better ways of doing that (as the other person mentioned).
Somebody in an online forum wrote: INTJs never really joke. They make a point. The joke is just a gift wrapper.
|
|
|
|
|
Hi All,
in anyways if I could do that or any one could give me some code or a link, it would have been better for me.
Thanks,
Abdul
Thanks & Regards,
Abdul Aleem Mohammad
St Louis MO - USA
|
|
|
|
|
Hi,
I am currently developing in windows form and can display the SSRS reports using the ReportViewer control...
Question:
1- Is it possible to display the SSRS reports via silverlight 4?
2- IS it as same as using the report viewer control as I do in windows forms?
Thanks
|
|
|
|
|
|
As Mark said there is no native report viewer in Silverlight. There is a 3rd party one available but it is expensive and only works with server based reports.
As I need embedded reports (RDLC) so I spawn an ASPX page passing the parameters in the url, while this works it is not satisfactory as the values are exposed and the spawned page just feels flaky. However it does give me a reporting solution in Silverlight, there are some articles on CP that helped.
Silverlight Report Viewer using View Model (MVVM)[^]
Integrate Reporting Services with Silverlight and RIA Services[^]
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Do you mean I can add an .aspx page into my silverlight application and have the report viewer control inside the .aspx page and then call the .aspx from the silverlight page?
|
|
|
|
|
This lives in the VM for my reports dialog
private void doReport(object o)
{
string sReport = o.ToString();
string sURL, sCriteria = string.Empty;
switch (sReport)
{
case"EquipmentList":
sCriteria = GetCriteriaEQ();
break;
case "EquipmentFleet":
sCriteria = GetCriteriaEQFleet();
break;
default:
break;
}
sURL = VML.ReportsVMStatic.GetReportsAddress(sReport, sCriteria);
gUI.ShowWindow(sURL);
AppMessage.DialogCompleted.Send(AppMessage.DialogCompleted.enDialogResult.eTrue);
}
GetCriteria returns a string with the criteria formatted specifically for a report and showwindow openns the aspx page
HtmlPage.Window.Navigate(oURI, "_blank");
The page_load of the aspx deals with the query string and gets the data from the database to service the RDLC. As I said ugly but works.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi,
I studied the link you sent. thanks.
It seems that a new form should be added to the silverlight project which then shows the SSRS report in a popup format?
|
|
|
|
|
Hello,
Is there some control in WPF that i can use to display a list.
For example i have a list of objects where each object have some number of properties.
I wannt to give this list to the control and he will display each object properties in a row when every propertie displayed in a separate column.
So my question is is there some control already in WPF.
If not i will have some how to create one but in order to create i have to know how many properties object has,how can i do it?
Thanks.
|
|
|
|
|
You could use a DataGrid and set AutoGenerateColumns="True" on it. This assumes that all your properties can be displayed textually - if you have images to display, for instance, you are going to have to take over control yourself. WPF can only go so far.
|
|
|
|
|
Check out ListView, it is customizable to some degree (with AutoGenerateColumns=false) and it will probably serve you just fine.
|
|
|
|
|
What is the difference/benefit between this and using ListBox? I thought ListView was supposed to be used with views (ViewBase-derived objects), like GridView - isn't that the case?
|
|
|
|
|
What I meant (and also in my replay to OP) is that ListView (as opposed to ListBox) can be used this way
<ListView>
<ListView.View>
<GridView>
<GridViewColumn DisplayMemberBinding="{Binding FirstName}" Header="First Name" />
...
</GridView>
<ListView.View>
</ListView>
where the individual columns can be either autogenerated or more or less customized. Which I assume is what the OP wanted. This displays the "grid-view" known for example from file explorer if you select display mode->details.
This is (I think) the primary purpose of ListView.
|
|
|
|
|
There is a huge difference between ListView and ListBox. ListBox just displays a flat list of items whereas ListView supports columns, grouping, etc.
|
|
|
|
|
Well, I had this problem where I got so many answers but they couldn't work together as I desired.
Now, I have a decimal (money) field from my repository.
After binding my collection to a grid using the Galasofts Mvvm framework, I want +ve values to take the #,###,###.## format and the -ve values to take the (#,###,###.##) format. Zero values will then take #.## format. All this formatting I want to happen in the xaml. Not in my view models.
Most solutions offered money formatting but the has the dollar sign, and we dont use dollars. Others wont cater for the negative value, and others will not cater for the decimals.
So the best solution is
“#,0.00;(#,0.00);0”
The first bit is the format for positive numbers.
The second bit is how negative numbers are displayed
The third bit is for zeros
Practical example:
Binding="{Binding Amount, StringFormat=#\,0.00;(#\,0.00);0}"
|
|
|
|
|
I love these, are we supposed to guess the question or telepathically download the requirement form the ether. This being a forum where you can get answers, it is common to ask a question to get a reasoned response (unlike this sarcastic missive).
On the other hand if this is a 'suggestion' and you are trying to help others (having beaten the internet into submission getting the answer) then I suggest you present this as a Tip/Trick where it can be dealt with correctly and will actually help other.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi All,
I am new to the Silverlight world. can anybody please help me in wrapping the text in the textblock which is there in the Canvas.
Is there any way to do it, please help me.
Thanks in Advance.
Thanks & Regards,
Abdul Aleem Mohammad
St Louis MO - USA
modified 25-Oct-11 20:56pm.
|
|
|
|
|
Set the TextBlock's TextWrapping property to TextWrapping.Wrap. A Canvas parent won't resize or clip the TextBlock so you'll need to handle that yourself.
Mark Salsbery
|
|
|
|
|
But if I use anyother container like stackpanel or grid then the text is taking all the browser width and making all the page uncomfortable.
What can I do, can you please help me, I am working around it, any link or any kind of help is greatly appreciated.
Thanks in advance. In no way I am getting it, please help me.
Thanks & Regards,
Abdul Aleem Mohammad
St Louis MO - USA
|
|
|
|
|
Set the width and height of the textblock explicitly.
Mark Salsbery
|
|
|
|