|
We implement a timeout and log the user off if there is no activity through the navigate method. If some poor bastard needs to sit and stare at a single page for more that 20 minutes then thats just tough, they are out of there.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi all,
I need to build TreeViewItems dynamically in Silverlight4, C#.net, Visual Studio 2010 Premium.
Currently the TreeView consists of only a lot of TextBlocks, and I need to put a CheckBox in front of each TextBlock dynamically. This has to be done in code-behind, not in the xaml.
I have done a few Google searches, but could not find anything that I could use to guide me to do this.
Please provide me with links to articles/demos/discussions/etc that will help me.
Some code snippits would be appreciated too...
Thanks
modified on Friday, August 5, 2011 7:45 AM
|
|
|
|
|
You should explain what you are trying to do. Telling us you need to dynamically build a UI from the code behind sounds like you are headed down the wrong path. I just wrapped up a customized TreeView that I wrote that does exactly what you are talking about... added checkbox and image support to the stock WPF TreeView. None of my code involves dynamically building the UI from the code behind. Its all in XAML via triggers, etc.
|
|
|
|
|
Done in XAML via triggers?
I have never heard of triggers in XAML.
What is it, and how are they used?
But I guess that's for another thread, huh.
I'll Google it...
|
|
|
|
|
Sledge has got it right, if you are using code to create a UI element you are doing it WRONG. Build you template in xaml with a stackpanel containing a checkbox and a textblock, bind them to your data collection. Your data collection may be manipulated from the code but not your UI element.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Thanks for the replies.
Additional Info: The UserControl that contains the TreeView is used on another page too, but NOT with the CheckBox. The functionality there requires the user to actually select the appropriate TreeViewItem. In the new scenario, the TreeView is be populated with exactly the same data is on the other page, but with the additional CheckBox for each TreeViewItem where the user is allowed to select multiple CheckBoxes in the TreeView. My idea was to just add the CheckBox to each TreeViewItem dynamically as each is built, and before it is added to the TreeViewItems collection.
Question: Should I put another grid in my XAML with exactly the same methods etc as for the original TreeView, but with the additional CheckBox as part of the TreeViewItemTemplate?
Then whenever this altered TreeView is needed, I toggle the visibility of the 2 grids in my XAML?
Thanks again for any directional advice and alternative suggestions.
|
|
|
|
|
Hi all,
This is how I did it.
I hope it helps someone in the future.
Microsoft.Windows.Controls.TreeViewItem treeitem = new Microsoft.Windows.Controls.TreeViewItem();
StackPanel sp = new StackPanel();
sp.Orientation = Orientation.Horizontal;
CheckBox cb = new CheckBox();
sp.Children.Add(cb);
sp.Children.Add(treeitem);
|
|
|
|
|
Hallo!
I developed a game for Windows Phone 7 (myStraights).
During the game you are able to enter numbers. I'm not satisfied with the solution I have.
The buttons are simple WPF buttons without
further change. I'm searching for a solution for following problem, maybe someone can help me:
I tried to create a virtual keyboard (but just with numeric values) like
the original virtual keyboard of the Windows Phone 7 (the original keyboard takes up too much space). When a button is pressed and somebody is moving his/her finger to another
button, the button raises the Mouse_Leave event and on the other button the Mouse_Enter event.
On the first button the Mouse_LeftButtonDown event occures. When you're leaving the original
button, the Mouse_LeftButtonUp event doesn't occure on another button when raising the finger, that's okay
What I did: In code I remember which button was the last "Mouse_Enter" button, when leaving the button and leaving the container of the button. Maybe the player wanted to press this button, but this is not for sure. The last position of the finger (observed throw the MouseMove event) is not reliable. I'm searching a method to determine whether the finger was over a button at the time on which the user raised the finger.
Thanks in advance, many greetings,
Thomas
|
|
|
|
|
hi i'm a wpf beginner and i have some question i was hoping that you may help me .
I'm developping a wpf project using MvvM light for WPF4 toolkit but I don't seem to make a connection with my SQL data base , I tried to do a databinding using ADO.net entity framework but it doesn't provide me class for each table, same thing for the methode Link to SQL ,
so I'm wondering what is the appropriate way to do a databinding that transform each table in my database to a class (as the model layer for the design pattern MvvM ) so i can manipulate it .
thanks for your concern and I hope you can really help me cause I'm totally clueless !
|
|
|
|
|
All custom context menus are styled using a common control template in the
application resource dictionary which overides the default style. This in turn affects the textbox contextmenu
and gives a distorted (cut, copy, paste) menu options. Is there a way to do except for
the contextmenu style of textbox?
<ControlTemplate
x:Key="{x:Static MenuItem.SubmenuItemTemplateKey}"
TargetType="MenuItem">
<!--
</ControlTemplate>
- Regards - J O N
A good thing is a bad thing if it keeps you from the best thing. - Dr. Adrian Rogers
|
|
|
|
|
If you give a ControlTemplate a key as you have above, its not applied to anything unless you specifically tell it to use that template. If it doesn't have an x:Key, its applied to everything.
|
|
|
|
|
Hello,
I have a RadGridView in my application. In that grid there is one column named "GridViewDataColumn" and in that column there is 3 buttons. Now out of 3 buttons I want to disable/enable one button on a particular condition. Can anybody Help me.
Regards,
Sunil G.
|
|
|
|
|
Look into cellstyleselecteor at Telerik, this allows you to manage a cell based on the content, not sure if it can be coerced into managing the content of the cell.
I would ask this in the Telerik support forums, I find them very helpful supporting their products.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Same issue[^] and the work around given here works perfect but has a disadvantage that designers cannot work on the UI part if we move the code to the converter. any alternate?
- Regards - J O N
A good thing is a bad thing if it keeps you from the best thing. - Dr. Adrian Rogers
|
|
|
|
|
Hello
How can i arrange user roles and groups at Silverlight bussines app.
Thanks...
|
|
|
|
|
You're questions are too generic, you are looking for design information in a forum post. This indicates you need to do some more study, either a book or peruse the articles on your subject. These question cannot be answered in a simple forum post.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hello,
i started building project with Silverlight bussines app.i added EntityModel and Domain Service,in Client side i can see entityobjects (like cars) i can not see CRUD controls(insert,update,delete ) ..
DomainService1 service= new DomainService1
service.insertCar is not shown.
What must i do.
Thanks.
|
|
|
|
|
I would like to do some simple math in my WPF application with as much XAML code as possible and with as little C# code as possible. I have looked at various examples how to do this on diffrent web pages, but they are either to complex or don't show all details or lacks code or is just a bad example.
Please run my XAML code, just copy and paste it:
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Window.Resources>
<Style x:Key="Alignment">
<Setter Property="Control.HorizontalAlignment" Value="Left"></Setter>
<Setter Property="Control.VerticalAlignment" Value="Top"></Setter>
</Style>
<Style x:Key="GroupBoxStyle" BasedOn="{StaticResource Alignment}">
<Setter Property="Control.BorderBrush" Value="Black"></Setter>
<Setter Property="Control.BorderThickness" Value="2"></Setter>
<Setter Property="Control.FontSize" Value="15"></Setter>
</Style>
<Style x:Key="Header">
<Setter Property="Control.FontSize" Value="15"></Setter>
<Setter Property="Control.FontWeight" Value="Bold"></Setter>
<Setter Property="Control.Height" Value="30"></Setter>
</Style>
</Window.Resources>
<Grid>
<GroupBox Header="Product schedule" Margin="0,0,0,0" Style="{StaticResource GroupBoxStyle}" Width="Auto" Height="Auto">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Label Content="Product" Grid.Row="0" Grid.Column="0" Style="{StaticResource Header}"></Label>
<Label Content="Weight (g)" Grid.Row="0" Grid.Column="1" Style="{StaticResource Header}"></Label>
<Label Content="Numbers" Grid.Row="0" Grid.Column="2" Style="{StaticResource Header}"></Label>
<Label Content="Total weight (g)" Grid.Row="0" Grid.Column="3" Style="{StaticResource Header}"></Label>
<Label Content="A" Grid.Row="1" Grid.Column="0"></Label>
<Label Content="126" Grid.Row="1" Grid.Column="1"></Label>
<TextBox Name="txtA" Grid.Row="1" Grid.Column="2"></TextBox>
<Label Name="lblATotalWeightGram" Grid.Row="1" Grid.Column="3"></Label>
<Label Content="B" Grid.Row="2" Grid.Column="0"></Label>
<Label Content="220" Grid.Row="2" Grid.Column="1"></Label>
<TextBox Name="txtB" Grid.Row="2" Grid.Column="2"></TextBox>
<Label Name="lblBTotalWeightram" Grid.Row="2" Grid.Column="3"></Label>
<Label Content="Total" Grid.Row="3" Grid.Column="0"></Label>
<Label Name="lblPiiGABTotal" Grid.Row="3" Grid.Column="2"></Label>
<Label Name="lblPiiGABTotalWeightGram" Grid.Row="3" Grid.Column="3"></Label>
<Label Name="lblPiiGABTotalWeightKiloGram" Grid.Row="3" Grid.Column="4"></Label>
</Grid>
</GroupBox>
</Grid>
</Window>
Notice I have two Textboxes to specify numbers of product A and product B.
I would like to calculate the following:
1) Total Weight in g for each product: A * 126 and B * 220
2) Calculate total amounth of products: A + B
3) Calculate total weight of all products: (A * 126) + (B * 220)
This should be done if I change any values in the TextBoxes.
Any help would be nice!
|
|
|
|
|
Short answer is "yes, it is possible".
The long answer is a lot less pleasant: it can't be done for free. Pulling this trick requires work. In fact, it requires a lot of work.
Here are the basic steps:
1. First, you need an expression library capable of evaluating expressions presented to it as strings. You can either build one (making a high-performance evaluation library on top of Linq expressions is surprisingly simple), or adopt one written by someone else (for example, this one: Expression Evaluator[^]).
2. Next, you will need to build a Converter class, which is a small adapter for using your expression evaluator in XAML. One class can implement both IMultiValueConverter.aspx[^] and IValueConverter[^], and expose a string property called "Source".
3. Import the assembly with your adapter into your XAML file by adding a clr-namespace referencing your assembly to the Windows element. xmlns:Converter="clr-namespace:MyNamespace.Converter;assembly=MyConverterAssembly"
4. Add a resource for each expression that you would like evaluated from your XAML:
<Converter:ExpressionValueConverter
x:Key="CalcTotalWeight"
Source="(arg1 * 126) + (arg2 * 220)"
/>
5. Use binding or multi-binding to attach your expression to labels and text boxes in your XAML:
<MultiBinding Converter="{StaticResource CalcTotalWeigh}" FallbackValue="0">
<Binding Path="txtA"/>
<Binding Path="txtB"/>
</MultiBinding>
I went through this exercise once, and I can tell you that it is not easy. And I started with a well-tested expression library from step 1! But once you put it all together, it looks like a small miracle.
|
|
|
|
|
Thanks!
Since I'm no master in XAML and I can practically do nothing if I don't have a simple and exact example, your guide will do me no good.
I think I will skip this method and use the old fashion C# way instead. Ugly but easy...
|
|
|
|
|
You could accomplish this entirely in your XAML by using inline code (it's not pretty, and it's not good practice, but it is possible). Basically, you would implement an <x:Code> section where you would put the code in place to handle the calculations, etc. The important thing to remember is that you should encode your code so that you have something that looks like this:<x:Code>
<![CDATA[
// Do your work here
]]>
</x:Code>
|
|
|
|
|
Thanks!
I tried that and it worked. But I don't like the method at all.
|
|
|
|
|
|
Hi,
I want to validate the controls in asp.net silverlight when click a button before save.
We need any validation controls or javascript?
i need to work same as asp.net validation control or javascript validation.
Regards,
YPKI
|
|
|
|
|
Your question does not make sense, you are asking for information about both asp.net and silverlight, in a silverlight forum. Either you are using silverlight or not, decide and then ask a more appropriate question.
You do not use javascript to validate silverlight input, javascript works in conjunction with asp (html) not xaml.
Never underestimate the power of human stupidity
RAH
|
|
|
|