|
Hi
Since I am building the columns from code-behind, I need to attach hyperlink into one of the columns from code behind. And also, I need to add the click event.
How can I do that and its data-binding in code behind? Please advise.
Thanks
AJ
Follow your goals, Means will follow you ---Gandhi---
|
|
|
|
|
I just did that in our own silverlight app (I assume you're talking about a regular Grid (as opposed to a DataGrid).
I simply created the button and set the Tag property indicating it's purpose (or associated data). This kept me from having to set a unique Name . After the button was created, I subscribed to the Click event (all buttons used the same event method), and then added the button to the appropriate grid column/row.
In the event handler, the Tag object indicated what the button was supposed to do.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
I have written a Silverlight 4 application that reads a data stream and interprets it to dynamically create a web page. As part of the design I need to add grids to the page to act as placeholders to mimic the appearance and behaviour of tables. Here I am dynamically creating a grid with [gridCols] number of columns:
Grid LocalGrid = new Grid();
LocalGrid.Width = Double.NaN; // Auto Width and Height
LocalGrid.Height = Double.NaN;
for (int c=1; c <= gridCols; c++) // Add the columns
{ // Add a new column to the grid
LocalGrid.ColumnDefinitions.Add(new ColumnDefinition() { MinWidth = 10.0 });
}
LocalGrid.Background = new SolidColorBrush(Colors.LightGray);
So far, so good. I can now add rows as I need them with:
LocalGrid.RowDefinitions.Add(new RowDefinition() { MinHeight = 15 });
When the grid is fully loaded and formatted I can add it to a placeholder on the web page.
So, question, how can I get at and programmatically alter the properties of the added rows? For example how can I set the background colour of a row to do an alternating-row colour scheme. I have seen examples of using the LoadingRow event, but this grid is not data-bound.
Grid rows do not have properties such as BackColor exposed. I'm guessing that I need to use SetValue but, if so, what are the required parameters and how can I see a list of the dependency properties?
Any help greatly appreciated.
Kind regards
Paul
________________
Eschew Obfuscation
Anon
|
|
|
|
|
I guess you might be adding one or more controls to every row that you create.
Setting the background color of the parent control in every alternate row may help you solve this problem.
This is definitely not an optimal way, but perhaps the only way (for a
Grid control).
Setting alternate row colors for an items control is relatively easier and uses the approach you have mentioned in your post (using LoadingRow).
|
|
|
|
|
Hi,
I have a problem with rotating a WPF UIElement and placing it within a small space.
Consider the following problem:
<Grid HorizontalAlignment="Center" VerticalAlignment="Center" Width="30" Height="100">
<Button Content="This is my button"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Width="100"
Height="30"
RenderTransformOrigin="0.5,0.5">
<Button.RenderTransform>
<RotateTransform Angle="90" />
</Button.RenderTransform>
</Button>
WPF seems to draw the grid, draw the button (with the sides cut off) and then rotate the button (without sides).
Has anyone encountered this problem before?
Shane
|
|
|
|
|
Try LayoutTransform instead of RenderTransform.
|
|
|
|
|
|
Hi,
I am planning to move my VBA/Excel application to WPF or WinForm C#, and adding some cool features. Basically I would like to load a map from google/Bing or manually, draw lines (pipe network) and after make some calculation on these lines. Until now I use several programs to do that Autocad for drawing, Excell for calculation etc.
There are already a lot of apps doing some part of what I want to achieve. Google Map for drawing lines on map, EPANET free framework for pipe networks - but no examples how to integrate its features into C#. Also, commercials editions WaterCAD of Bentley and ArcGIS.
So my question is … will WPF relief my pain or should I stick with WinForm to achieve the above?
|
|
|
|
|
I have a ListBox with a custom item template, as follows:
<ListBox x:Name="AheadListBox"
FontSize="20"
BorderBrush="Transparent" BorderThickness="0,0,0,0"
Background="Transparent"
ScrollViewer.VerticalScrollBarVisibility="Auto"
ScrollViewer.HorizontalScrollBarVisibility="Hidden">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Ellipse Grid.Column="0" Width="20" Height="20"
VerticalAlignment="Top"
HorizontalAlignment="Left"
Margin="5,0,0,0">
<Ellipse.Fill>
<RadialGradientBrush GradientOrigin=".5,.3">
<GradientStop Color="LightSteelBlue" Offset="0.05"/>
<GradientStop Color="DarkBlue" Offset="0.9"/>
<GradientStop Color="DarkBlue" Offset="1"/>
</RadialGradientBrush>
</Ellipse.Fill>
</Ellipse>
<TextBlock Grid.Column="1"
Text="Some really long text string to test the veracity of my XAML Layout. Of course, nothing works the first time where Silverlight is concerned"
Margin="10,0,10,0"
TextWrapping="Wrap" />
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
I want the TextBlock to automatically grow vertically to accomodate all of the text it contains. Things I've tried:
0) At first, I had a StackPanel for a container, but I changed to a Grid to see if that would fix it (no fix was forthcoming).
1) I tried using a Label control instead of a TextBlock .
2) If I manually insert a "\r\n" somewhere in the string, it will grow as expected, but that's not the way the text will be fed to the control.
3) Setting Height="Auto" doesn't appear to have any effect.
4) I also tried calling ListBox.InvalidateMeasure() and ListBox.InvalidateArrange() after the listbox was populated.
5) If I set a hard-coded width for the TextBlock in the XAML, the TextBlock grows vertically as expected.
One other aspect of control (just in case you missed it) - the ListBox is set to expand/contract with its parent container, so the amount of space available to the listbox item will change accordingly.
It's starting to look like I have to do this manually. So much for separating the layout from the business logic...
SOLUTION ===============================
I had to set the horizontal scrollbar to disabled. Once I did that, it bahaved the way I thought it was supposed to.
.45 ACP - because shooting twice is just silly----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
modified on Thursday, May 13, 2010 1:17 PM
|
|
|
|
|
Hi,
I am using LINQ to SQL and MVVM pattern in my application where i am retrieving
my data by the following query:
internal ObservableCollection<INVCategory> GetCategoryList()
{
DataLoadOptions dataLoadOptions = new DataLoadOptions();
dataLoadOptions.LoadWith<INVCategory>(t => t.INVSubCategories);
this.Context.LoadOptions = dataLoadOptions;
var categories = from category in this.Context.INVCategories
orderby category.CatgeoryId descending
select category;
return new ObservableCollection<INVCategory>(categories.ToList());
}
And my XAML code for parent(Category) combo is:
<ComboBox Grid.Column="1" Grid.Row="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="0,2,10,2" TabIndex="0" x:Name="categoryComboBox"
ItemsSource="{Binding CategoryList}" IsEditable="True" DisplayMemberPath="CategoryName" SelectedValuePath="CatgeoryId" SelectedItem="{Binding CategoryList, Mode=TwoWay}" SelectedValue="{Binding Path=CurrentEntity.CategoryId, Mode=TwoWay}" >
</ComboBox>
for child(Subcategory) combo i am using:
<ComboBox Grid.Column="1" Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="0,2,10,2" TabIndex="1"
ItemsSource="{Binding SelectedItem, ElementName=categoryComboBox, Mode=OneWay}"
DisplayMemberPath="SubCategoryName" SelectedValuePath="SubCategoryId"
SelectedItem="{Binding INVSubCategories, Mode=TwoWay}">
</ComboBox>
But my child combo items is not populated during form loading as well as parent combo's
selection changed though my parent combo items are populated.
i can't figure out why my child combo is not functioning based on parent combo's
selected item ,please help me.
|
|
|
|
|
Check whether you implemented INotifyPropertyChanged interface for Category class object.
|
|
|
|
|
Thanks Castle Rider for your reply.
I have made a Generic "BasePresenter" class where i have implemented INotifyPropertyChanged interface in the following way:
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged(string propertyName)
{
PropertyChangedEventHandler handler = this.PropertyChanged;
if (handler != null)
{
handler(this, new PropertyChangedEventArgs(propertyName));
}
}
And in my Presenter class I have used:
public ObservableCollection<INVCategory> CategoryList
{
get
{
return this.categoryList;
}
set
{
this.categoryList = value;
OnPropertyChanged("CategoryList");
}
}
|
|
|
|
|
Try adding UpdateSourceTrigger=PropertyChanged along with the ItemsSource Binding xaml.
|
|
|
|
|
I am not clear. Would you please send me a sample code.
|
|
|
|
|
Try this binding in categoryCombo
SelectedValue="{Binding Path=CurrentEntity.CategoryId, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
|
|
|
|
Hello,
My machine has xp pro 64bit.
I currently have VS2008.
Can you see why I can not install VS2010 express please?
The error is:
DownloadManager Information: 0 : Loading product xml from 'https://go.microsoft.com/fwlink/?LinkId=158722'
DownloadManager Information: 0 : Product manager downloading: https://go.microsoft.com/fwlink/?LinkId=158722
DownloadManager Information: 0 : Remote file has not changed, using local cached file:C:\Documents and Settings\Administrator\Local Settings\Application Data\Microsoft\Web Platform Installer\-2016837979.xml.temp
DownloadManager Information: 0 : Loading product xml from 'https://www.microsoft.com/web/webpi/2.0/WebApplicationList.xml'
DownloadManager Information: 0 : Product manager downloading: https://www.microsoft.com/web/webpi/2.0/WebApplicationList.xml
DownloadManager Information: 0 : Remote file has not changed, using local cached file:C:\Documents and Settings\Administrator\Local Settings\Application Data\Microsoft\Web Platform Installer\-1244381891.xml.temp
DownloadManager Information: 0 : Filtering by majorOS: 5, minorOS: 2, majorSP: 2, minorSP: 0, productType: 1, architecture: x64
DownloadManager Information: 0 : Filtering by majorOS: 5, minorOS: 2, majorSP: 2, minorSP: 0, productType: 1, architecture: x64
DownloadManager Information: 0 : Contextual entry products: VWD2010
DownloadManager Information: 0 : Adding product Visual Web Developer 2010 Express (VWD2010) to cart
DownloadManager Information: 0 : Contextual navigation to product 'VWD2010'
DownloadManager Information: 0 : Product 'VWD2010' was already in cart.
DownloadManager Information: 0 : No SQL to configure
DownloadManager Information: 0 : No MySQL to configure
DownloadManager Information: 0 : Setting current install to 1
DownloadManager Information: 0 : Starting install sequence
DownloadManager Information: 0 : Using cached file at C:\Documents and Settings\Administrator\Local Settings\Application Data\Microsoft\Web Platform Installer\installers\VWD2010\dd6b1454fe3f90ea126cf550ae344f8e5b831786\vwd_web.exe instead of downloading from http://download.microsoft.com/download/0/D/6/0D600544-AD1A-45FB-8D40-838EBF3C03EC/vwd_web.exe
DownloadManager Information: 0 : Starting EXE install for product 'Visual Web Developer 2010 Express'. Commandline is: 'C:\Documents and Settings\Administrator\Local Settings\Application Data\Microsoft\Web Platform Installer\installers\VWD2010\dd6b1454fe3f90ea126cf550ae344f8e5b831786\vwd_web.exe /x:C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\vwd\ /q'
DownloadManager Information: 0 : Waiting for process: 2876 - C:\Documents and Settings\Administrator\Local Settings\Application Data\Microsoft\Web Platform Installer\installers\VWD2010\dd6b1454fe3f90ea126cf550ae344f8e5b831786\vwd_web.exe
DownloadManager Information: 0 : Install exit code for product 'Visual Web Developer 2010 Express' is 0
DownloadManager Information: 0 : Starting EXE install for product 'Visual Web Developer 2010 Express'. Commandline is: 'C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\vwd\setup.exe /q /norestart /web'
DownloadManager Information: 0 : Waiting for process: 5104 - C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\vwd\setup.exe
DownloadManager Information: 0 : Install exit code for product 'Visual Web Developer 2010 Express' is 5100
DownloadManager Error: 0 : Install return code for product 'Visual Web Developer 2010 Express' is Failure
DownloadManager Information: 0 : Product Visual Web Developer 2010 Express done install completed
DownloadManager Information: 0 : Increasing current install to 2
|
|
|
|
|
|
Hi Michel,
I do not follow what you mean. Please explain. thanks
|
|
|
|
|
You have an error 5100 during setup (generic setup block). The causes for error 5100 are explained in the link
|
|
|
|
|
What SP should I have on my xp pro 64bit pls?
|
|
|
|
|
Well, normally SP3 is the latest and greatest, but I don't think it exists for XP-64. SP2 is the last there. The problem might be that setup checks for SP3, and buggers off. In that case, you have a definite problem.
If you think this is your problem, you'd better post a new question (preferably in the .Net forum), asking something like 'has anyone installed VS 2010 on XP professional 64 bit edition, and what are the problems/requirements'. Have a google also, someone may have had the same problem.
|
|
|
|
|
Is it ok to have VS 2005 and 2008 installed already and then install VS 2010 express?
Before installing vs 2010 express, should I uninstall 2005 and 2008 versions?
Thanks
|
|
|
|
|
NORMALLY, they should be able to run side by side. But I've heard so many problems, (especially if BETA versions were involved), that grown men were driven to tears, and had to re-install their whole system after taking 3 aspirins, invoking their personal totem in the Valhalla, and decorating their body with old MSDN Cd's.
Your mileage may vary
|
|
|
|
|
Those CDs can irritate the skin, too. Microsoft obviously didn't test them with a very wide range of adhesives.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
I can't seem to figure out how to apply Commanding to a TreeView node change. Google is sparse on the subject.
Anyone have an example of this?
Everything makes sense in someone's mind
|
|
|
|
|