|
|
It still could be one of the controls causing it. i have not tested SL4 to see if anything there leaks.
Steve Maier
|
|
|
|
|
New to Silverlight - Using four areas Three of which looking for guidance to make a combo box work in a Silverlight Grid from a stored procedure:
Any thoughts are much appreciated
Hello,
I am new to silverlight. Can some please guide me with the appropriate syntax for displaying a combo lookup box which is being loaded by a stored procedure? In addition, can you tell me how to turn on and off the Display of the combo box. It requires two clicks to open the combo box. Here is my code:
XAML
<sdk:datagridtemplatecolumn x:name="patIdEssentrisColumn" header="Pat Id Essentris" width="SizeToHeader">
<sdk:datagridtemplatecolumn.celltemplate>
<datatemplate>
<textblock margin="2" text="{Binding PatIdEssentris}">
<sdk:datagridtemplatecolumn.celleditingtemplate>
<datatemplate>
<combobox name="cboTest"
=""
itemssource="{Binding GetComboboxItems_PatIdEssentris}"
displaymemberpath="PatientName">
Combo Box Class
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
namespace CorporateHR.Web
{
public class ComboBoxItem
{
[Key]
public int ComboID_Int { get; set; }
public string ComboDisplayValue { get; set; }
private static List<comboboxitem> GetComboBoxItems(string strStoredProcedure)
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["RefConnectionString"].ConnectionString);
SqlCommand cmd = new SqlCommand(strStoredProcedure, con);
cmd.CommandType = System.Data.CommandType.StoredProcedure;
List<comboboxitem> comboList = new List<comboboxitem>();
con.Open();
SqlDataReader dr = cmd.ExecuteReader(behavior: CommandBehavior.CloseConnection);
while (dr.Read())
{
ComboBoxItem ComboBoxItem = new ComboBoxItem();
ComboBoxItem.ComboID_Int = Convert.ToInt32(dr[0].ToString());
ComboBoxItem.ComboDisplayValue = dr[1].ToString();
comboList.Add(ComboBoxItem);
}
return comboList;
}
public static List<comboboxitem> GetComboboxItems_PatIdEssentris()
{
return GetComboBoxItems("uspLookupPatIdEssentris");
}
//Secondary ComboBox Lookup:
public static List<comboboxitem> GetComboboxItems_Department()
{
return GetComboBoxItems("uspLookupPatIdEssentris");
}
}
}
Code Behind Page
namespace CorporateHR
{
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using CorporateHR.LoginUI;
public partial class MainPage : UserControl
{
public MainPage()
{
InitializeComponent();
this.loginContainer.Child = new LoginStatus();
this.Loaded += new RoutedEventHandler(Page_Loaded);
}
void Page_Loaded(object sender, RoutedEventArgs e)
{this.employeeDataGrid.ItemsSource = GetComboboxItems_PatIdEssentris();}
private object GetComboboxItems_PatIdEssentris()
{
throw new System.NotImplementedException();
}
|
|
|
|
|
What do you mean when you say ?
can you tell me how to turn on and off the Display of the combo box
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
My combo box works outside the grid, but it does not work inside the grid.
Question: how do I make a combo box work inside of a grid.
The following code works fine outside of the grid, but does not work in the grid. How do I make this work inside the grid?
<u><b>This works outside of the Grid:</b></u>
<ComboBox Height="23" HorizontalAlignment="Left" ItemsSource="{Binding ElementName=comboBoxItemDomainDataSource, Path=Data}" Margin="112,72,0,0" Name="comboBoxItemComboBox" VerticalAlignment="Top" Width="185" SelectionChanged="comboBoxItemComboBox_SelectionChanged" DisplayMemberPath="ComboDisplayValue">
<ComboBox.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel />
</ItemsPanelTemplate>
</ComboBox.ItemsPanel>
</ComboBox>
</Grid>
<riaControls:DomainDataSource AutoLoad="True" d:DesignData="{d:DesignInstance my:ComboBoxItem, CreateList=true}" Height="0" LoadedData="comboBoxItemDomainDataSource_LoadedData" Name="comboBoxItemDomainDataSource" QueryName="GetComboboxItems_PatIdEssentrisQuery" Width="0">
<riaControls:DomainDataSource.DomainContext>
<my:ComboBoxItemContext />
</riaControls:DomainDataSource.DomainContext>
</riaControls:DomainDataSource>
<u><b>This does not work within the Grid:</b></u>
<sdk:DataGridTemplateColumn x:Name="patIdEssentrisColumn" Header="Pat Id Essentris" Width="SizeToHeader">
<sdk:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Margin="2" Text="{Binding PatIdEssentris}" />
</DataTemplate>
</sdk:DataGridTemplateColumn.CellTemplate>
<sdk:DataGridTemplateColumn.CellEditingTemplate>
<DataTemplate>
<ComboBox Name="cboPatIdEssentris"
ItemsSource="{Binding Source={StaticResource comboBoxItemDomainDataSource}, Path=Data}"
DisplayMemberPath="PatientName"
/>
</DataTemplate>
</sdk:DataGridTemplateColumn.CellEditingTemplate>
</sdk:DataGridTemplateColumn>
-- Modified Friday, February 11, 2011 4:32 PM
|
|
|
|
|
You may want to edit your post. Basically, you've added code that appears as HTML type tags; in other words, they are between <>tags. What you need to do is convert your tags to be <> tags so that they will display properly.
|
|
|
|
|
Hopefully this will show up now...
This works outside the grid:
<ComboBox Height="23" HorizontalAlignment="Left" ItemsSource="{Binding ElementName=comboBoxItemDomainDataSource, Path=Data}" Margin="112,72,0,0" Name="comboBoxItemComboBox" VerticalAlignment="Top" Width="185" SelectionChanged="comboBoxItemComboBox_SelectionChanged" DisplayMemberPath="ComboDisplayValue">
<ComboBox.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel >
<ItemsPanelTemplate>
<ComboBox.ItemsPanel>
<ComboBox>
<Grid>
<riaControls:DomainDataSource AutoLoad="True" d:DesignData="{d:DesignInstance my:ComboBoxItem, CreateList=true}" Height="0" LoadedData="comboBoxItemDomainDataSource_LoadedData" Name="comboBoxItemDomainDataSource" QueryName="GetComboboxItems_PatIdEssentrisQuery" Width="0">
<riaControls:DomainDataSource.DomainContext>
<my:ComboBoxItemContext >
<riaControls:DomainDataSource.DomainContext>
<riaControls:DomainDataSource>
This does not work inside the grid:
< sdk:DataGridTemplateColumn x:Name="patIdEssentrisColumn" Header="Pat Id Essentris" Width="SizeToHeader">
< sdk:DataGridTemplateColumn.CellTemplate>
< DataTemplate>
< TextBlock Margin="2" Text="{Binding PatIdEssentris}" >
< DataTemplate>
< sdk:DataGridTemplateColumn.CellTemplate>
< sdk:DataGridTemplateColumn.CellEditingTemplate>
< DataTemplate>
< ComboBox Name="cboPatIdEssentris"
ItemsSource="{Binding Source={StaticResource comboBoxItemDomainDataSource}, Path=Data}"
DisplayMemberPath="PatientName"
>
< DataTemplate>
< sdk:DataGridTemplateColumn.CellEditingTemplate>
< sdk:DataGridTemplateColumn>
|
|
|
|
|
Hi,
How is it possible to fill the eclipse control with Green or red?
The following does not work and I can not find an example for this issue.
eclcontrol.Fill = "Green";
Thanks
|
|
|
|
|
The reason you are having a problem is because you have to use a brush to paint the colour in. So, you need to set your code to:
SolidColorBrush brush = new SolidColorBrush();
brush.Color = Colors.Green;
ellipse.Fill = brush;
|
|
|
|
|
I see.
I thought it was as easy as just setting the colour.
It makes sense now.
thank you.
|
|
|
|
|
The reason you need to use a brush is that Silverlight (and WPF) allow a lot of control over the painting, and this is achieved through the brushes. For instance, it's trivial to draw a gradient in Silverlight - it's a lot less so in GDI+.
|
|
|
|
|
I just can't seem to locate anything that gives me definitive stuff on being able to host multiple individual SilverLight applications on one web page.
I am looking to be able to create a few different individual SilverLight apps and place then on different areas of the page so the user can interact with them individually.
Just seem to be having a hard way to show how this is done.
Any good examples anyone is aware of?
|
|
|
|
|
What you might want to do is use a composite application block provided by Microsoft.
Using this block, a huge Silverlight application can be broken up into smaller modules (these can be nothing but different xap files).
Each of the files can then be run side by side on the same webpage.
Multiple xap files are loaded into different regions .
Link here[^].
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
My latest tip/trick
modified on Saturday, February 5, 2011 11:58 PM
|
|
|
|
|
Hmmm.. Thanks for the info. Looks like I have a bunch of reading to do
Just relay odd that I don't ever really seem to see any videos on the web about doing this type of stuff.
Maybe that's a hint to me to do something...
|
|
|
|
|
You absolutely can do that - the old Silverlight.net site did it, and I also ripped off the idea for interactive "islands" in a web page....it's as simple as you'd think too - just add multiple tags pointing to differnet .xaps.
I'd avoid the CAB approach unless you need communication between the apps...it's good, but a little OTT for simple stuff...
C# has already designed away most of the tedium of C++.
|
|
|
|
|
I will have to play around and give it a whack this weekend.
Thanks.
|
|
|
|
|
Hello Everyone
I have created a Client/Server application on C# on WPF IDE and I have a little problem on my UserClient property class...
Within this class I have a method called:
public override bool Equals(object obj)
{
UserClient temp = obj as UserClient;
if (temp != null)
{
return (userId == temp.userId);
}
if (temp != null)
{
return (userPass == temp.userPass);
}
return false;
}
The problem I'm having is:
The class UserClient is highlighted with a green line under-neath where when I place MouseOver it sas:
UserClient overrides Object.Equals but does not override Object.GetHashCode
Here is the entire UserClient class code:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
namespace DtposClient
{
public class UserClient
{
private string UserFullName;
private string UserAccessLevel;
private int UserId;
private int UserPassword;
public string fullName
{
get { return UserFullName; }
set { UserFullName = value; }
}
public string accLevel
{
get { return UserAccessLevel; }
set { UserAccessLevel = value; }
}
public int userId
{
get { return UserId; }
set { UserId = value; }
}
public int userPass
{
get { return UserPassword; }
set { UserPassword = value; }
}
public override bool Equals(object obj)
{
UserClient temp = obj as UserClient;
if (temp != null)
{
return (userId == temp.userId);
}
if (temp != null)
{
return (userPass == temp.userPass);
}
return false;
}
public UserClient(string fullNam, string aLevel, int usId, int pass)
{
fullName = fullNam;
accLevel = aLevel;
userId = usId;
userPass = pass;
}
}
}
Could someone please help me crack this problem....
thanks in advance
kind regards
lapeci
|
|
|
|
|
lapeci, forum guidelines state "do not post the same question in more than one forum." see answer to question in C# forum.
"You get that on the big jobs."
|
|
|
|
|
That's easy. Whenever you override Equals , you are required to override GetHashCode . All you need to do is add an override for this method.
The reason you need to do this is because you have changed the way equality works, so without a custom hashcode, you can end up with two different objects with the same hashcode - hence a problem with equality.
BTW, you should have posted this in the C# forum as it's a generic C# problem. The fact that the application is WPF is neither here nor there.
|
|
|
|
|
You can always use the new method to create a method of your own (breaking away from the inheritance hierarchy).
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
My latest tip/trick
|
|
|
|
|
public class TreeItem
{
public string HeaderTag { get; set; }
public List<TreeStatusItem> StatusItems { get; set; }
public List<TreeItem> items { get; set; }
public TreeItem()
{
StatusItems = new List<TreeStatusItem>();
}
}
public class TreeStatusItem
{
#region Properties
[DataMember]
public string StatusText { get; set; }
[DataMember]
public string StatusValue { get; set; }
}
Here a TreeItem has a HaderTag which displays as the Header for the treeview, the StatusItems contains items of a different type and the items have a List of the container class itself.
The sample data would be
-RegionName(object of TreeItem type)
--Oustanding(object of TreeStatusItem type)
--Live (object of TreeStatusItem type)
--Areas(object of TreeItem type)
----Oustanding(object of TreeStatusItem type)
----Live (object of TreeStatusItem type)
----SubAreas(object of TreeItem type)
......
...
I need to bind the data which is List<TreeItem> to a silverlight treeview. I can`t figure out how the hierarchical template should be !!!!
When you fail to plan, you are planning to fail.
|
|
|
|
|
I create a class ReportNode, it uses the NodeTag property to store the actual record that is used to populate the treenode
public class ReportNode : ViewModelBase
{
public ReportNode(string sLabel, object oObject, string sColor)
{
NodeLabel = sLabel;
NodeTag = oObject;
Color = sColor;
}
public string NodeLabel { get; set; }
public object NodeTag { get; set; }
public string Color { get; set; }
private ObservableCollection<ReportNode> _ChildNodes;
public ObservableCollection<ReportNode> ChildNodes
{
get
{ return _ChildNodes; }
set
{
_ChildNodes = value;
base.OnPropertyChanged("ChildNodes");
}
}
}
Hierarchical data template binds the itemssource to the ChildNodes collection.
When loading the nodes I stuff the NodeLabel with the text to display and the list object goes in the NodeTag property. When accessing the node I test the typeof the nodetag to determine what to do with the node. I have 1 tree with 6 different data sources, works perfectly.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Incorrect post.
Sorry
modified on Friday, February 4, 2011 5:51 AM
|
|
|
|
|
Stop posting multiple versions of the same question. You could follow this through in one thread, so that is what you should do. Honestly, you've asked more than enough questions on the forums to know this - and, btw, you should try to avoid the code behind; read about MVVM.
|
|
|
|
|
My database table contains two fields, id and name
What is the way to populate the combobox with the projectnames and have the id of each projectname assigned aswell.
This is required so that if for example, from a list of names in a listbox, a name is selected, then I want the projectname to be selected in the project combobox.
The table returns the name and the projectID
I can populate the combobox with the projectnames from the project table but not sure how to assign the IDs to them.
<ComboBox Name="cboProjects" SelectedIndex="{Binding Path=ProjectID}"
/>
Thanks
|
|
|
|