|
okay. If you don't want to go to my blog, I will post those issues here. Hope, you may suggest something...
* No SelectedItem: There is no dependency property called SelectedItem or equalivalient in xamlDatagrid. But they do have SelectedItems (with s). I wonder what wrong with SelectedItem. I don’t allow the user to select more than one row at a time so why do I need to loop through the SelectionItem list to get that selected item. Weird.
* Can’t get the reference of controls inside the Datagird: Maybe, I don’t know the correct way of doing this. And also, there is no documentation or sample for that. I tried to use VisualTreeHelper class to walk throught each and every element of Datagird but I just can’t find the controls which are inside DataTemplate. (It’s so easy to do with Xceed Datagrid.). Okay. Never mind.
* Showing the incorrect record if the datasource has some filters: I was using ListCollectionView as a datasource to bind the datagrid. There are some records that need to be excluded so I used the filter predicate for excluding those unnessary records. Then, I binded that ListCollectionView with Datagird. It works for the first time. So, I added new record to ListCollectionView and make it refresh. Opps! it shows the exclued record. crazy! then, I put WPF listview to find out whether this is a ListCollectionView problem or datagrid problem. And I found that it’s working fine with ListView. This issue is really crazy..
* Showing wrong checkedstate when scrolling: Here is another crazy issue. I created three columns for Datagrid in XAML. One of three columns has the checkbox inside. I showed around 30 records on the datagrid but only 10 rows are viewable within datagrid since I specify the height of datagrid explicitly. Then, I run the problem and checked a couple of checkbox. After that, I scrolled up and down a bit then the checkbox that I haven’t checked are automatially checked after scrolling.
|
|
|
|
|
Just reading the bit you did on XamDataGrid (since this is what I have most experience with) ...
1. Their "SelectedItem" is called "ActiveRecord" ...
2. I have loads of embedded controls in our grids with no problems. All easily controlable, I have some dynamically animated based on the grids contents as well.
3. In the app I'm doing for my company I used filters extensively to sort the results in the grid, not sure why you'd see problems here.
4. Not sure what is going wrong here, they did have an issue with the checkboxes that was fixed in a hotfix some months ago now.
Anyway, seems like you decicded on Xceed now. Although I'm not sure you have given them all a good thorough testing however.
|
|
|
|
|
Jammer wrote: 1. Their "SelectedItem" is called "ActiveRecord" ..
Is this bindable? Let's say I bind this "ActiveRecord" with AA Get/Set property. If I select one row after another on datagrid, can i get the selected record from AA property?
Jammer wrote: 2. I have loads of embedded controls in our grids with no problems. All easily controlable, I have some dynamically animated based on the grids contents as well.
How can I get the reference of those embedded controls? I wanna use like DG.Row[1].Cell[1].FindControl("myextendedtextbox")
Jammer wrote: 3. In the app I'm doing for my company I used filters extensively to sort the results in the grid, not sure why you'd see problems here.
Are you using ListCollectionView.Filter? Did you bind it to Datagrid? Have you tried to add new item to that ListCollectionView? I'm not sure why I got that error, man.
>>seems like you decicded on Xceed now.
Not yet. I'm doing with Telerik Datagrid before I got the solution from Xceed. If Xcced can give me some solutions, I may use that grid. Otherwise, I hav to go with Telerik....
|
|
|
|
|
.NET 3.5 SP1 now includes a datagrid
Link[^]
|
|
|
|
|
Good people,
I have assigned several items (including the background of my MainWindow) to a particular brush. My strategy is that instead of changing several different components (e.g. border background colors, border colors, control background colors, etc...), I can just change the color of the brush they all use via procedural code. The colors will change based on user preferences.
Unfortunately, when I try to do that, it doesn't work. The code is as follows:
public void SetClassicThemeBrushes()
{
// WindowMainBackground
Brush WindowMainBackgroundBrush = (Brush)TryFindResource("BrushWindowMainBackground");
WindowMainBackgroundBrush = (Brush)TryFindResource("MyCoolBreezeGradientBrush");
}
In the first line of code, attempt to get a reference to the existing brush that the components are assigned to. In the second line of code, I try to assign another color brush to the WindowMainBackground brush hoping it changes its color. Now I am wondering if all I have done is change a reference and not the color. Any idea on how I change the colors?
Any thoughts?
Thanks,
BP
|
|
|
|
|
You could either set a new value in the resource dictionary:
Resources["BrushWindowMainBackground"] = (Brush)TryFindResource("MyCoolBreezeGradientBrush");
Or change the brush itself, I don't know if this would work in all situations but it seemed to in this one.
SolidColorBrush b = (SolidColorBrush)TryFindResource("BrushWindowMainBackground");
b.Color = Colors.Green;
Also make sure your using DynamicResource in the xaml and not StaticResource.
|
|
|
|
|
Thanks, I will try that and see what happens.
Also, what do you think about using styles?
|
|
|
|
|
Actually, it worked. By the way, what do the Brackets "[]" mean? What do they do that parentheses would not?
Thanks,
BP
|
|
|
|
|
This is something you need to plan carefully imho.
At work I've spent about a month putting together/organising thousands of lines of styles into a style dll. We are planning on having a few 'skins' that users can choose from. Personally I prefer the idea of offering skins over allowing a user to change individual colours since that can wind up with an horrific mish mash of contrasting rubbish in the UI.
Have a look at this article on CP its where I started along this path and its a seriously cool CP article in general that covers this topic really well.
http://www.codeproject.com/KB/WPF/wpfskins.aspx[^]
|
|
|
|
|
Hey guys.
I'm totally new to WPF and I'm trying to write a control with it. The control is a calender and will be used as a roster where the user will select a shift to use for a specific day and then when one cycle has been set up the user must be able to copy that cycle for the rest of the year for example.
Here is the XAML code i have so far... Sorry if its a bit long
<UserControl x:Class="WPF_Calender_Control.UserControl1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Height="350 " Width="420">
<Grid >
<Grid.RowDefinitions>
<RowDefinition Height="25*" Focusable="True" />
<RowDefinition Height="25*" Focusable="True" />
<RowDefinition Height="60*" Focusable="True" />
<RowDefinition Height="60*" Focusable="True" />
<RowDefinition Height="60*" Focusable="True" />
<RowDefinition Height="60*" Focusable="True" />
<RowDefinition Height="60*" Focusable="True" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="60*" />
<ColumnDefinition Width="60*" />
<ColumnDefinition Width="60*" />
<ColumnDefinition Width="60*" />
<ColumnDefinition Width="60*" />
<ColumnDefinition Width="60*" />
<ColumnDefinition Width="60*" />
</Grid.ColumnDefinitions>
<Rectangle Fill="LightGreen" Grid.Column="0" Grid.Row="1"/>
<Rectangle Fill="LightGreen" Grid.Column="1" Grid.Row="1"/>
<Rectangle Fill="LightGreen" Grid.Column="2" Grid.Row="1"/>
<Rectangle Fill="LightGreen" Grid.Column="3" Grid.Row="1"/>
<Rectangle Fill="LightGreen" Grid.Column="4" Grid.Row="1"/>
<Rectangle Fill="LightGreen" Grid.Column="5" Grid.Row="1"/>
<Rectangle Fill="LightGreen" Grid.Column="6" Grid.Row="1"/>
<Border Grid.Column="0" Grid.Row="1" BorderBrush="Black" BorderThickness="1"/>
<Border Grid.Column="1" Grid.Row="1" BorderBrush="Black" BorderThickness="1"/>
<Border Grid.Column="2" Grid.Row="1" BorderBrush="Black" BorderThickness="1"/>
<Border Grid.Column="3" Grid.Row="1" BorderBrush="Black" BorderThickness="1"/>
<Border Grid.Column="4" Grid.Row="1" BorderBrush="Black" BorderThickness="1"/>
<Border Grid.Column="5" Grid.Row="1" BorderBrush="Black" BorderThickness="1"/>
<Border Grid.Column="6" Grid.Row="1" BorderBrush="Black" BorderThickness="1"/>
<Border Grid.Column="0" Grid.Row="2" BorderBrush="Black" BorderThickness="0.5"/>
<Border Grid.Column="1" Grid.Row="2" BorderBrush="Black" BorderThickness="0.5"/>
<Border Grid.Column="2" Grid.Row="2" BorderBrush="Black" BorderThickness="0.5"/>
<Border Grid.Column="3" Grid.Row="2" BorderBrush="Black" BorderThickness="0.5"/>
<Border Grid.Column="4" Grid.Row="2" BorderBrush="Black" BorderThickness="0.5"/>
<Border Grid.Column="5" Grid.Row="2" BorderBrush="Black" BorderThickness="0.5"/>
<Border Grid.Column="6" Grid.Row="2" BorderBrush="Black" BorderThickness="0.5"/>
<Border Grid.Column="0" Grid.Row="3" BorderBrush="Black" BorderThickness="0.5"/>
<Border Grid.Column="1" Grid.Row="3" BorderBrush="Black" BorderThickness="0.5"/>
<Border Grid.Column="2" Grid.Row="3" BorderBrush="Black" BorderThickness="0.5"/>
<Border Grid.Column="3" Grid.Row="3" BorderBrush="Black" BorderThickness="0.5"/>
<Border Grid.Column="4" Grid.Row="3" BorderBrush="Black" BorderThickness="0.5"/>
<Border Grid.Column="5" Grid.Row="3" BorderBrush="Black" BorderThickness="0.5"/>
<Border Grid.Column="6" Grid.Row="3" BorderBrush="Black" BorderThickness="0.5"/>
<Border Grid.Column="0" Grid.Row="4" BorderBrush="Black" BorderThickness="0.5"/>
<Border Grid.Column="1" Grid.Row="4" BorderBrush="Black" BorderThickness="0.5"/>
<Border Grid.Column="2" Grid.Row="4" BorderBrush="Black" BorderThickness="0.5"/>
<Border Grid.Column="3" Grid.Row="4" BorderBrush="Black" BorderThickness="0.5"/>
<Border Grid.Column="4" Grid.Row="4" BorderBrush="Black" BorderThickness="0.5"/>
<Border Grid.Column="5" Grid.Row="4" BorderBrush="Black" BorderThickness="0.5"/>
<Border Grid.Column="6" Grid.Row="4" BorderBrush="Black" BorderThickness="0.5"/>
<Border Grid.Column="0" Grid.Row="5" BorderBrush="Black" BorderThickness="0.5"/>
<Border Grid.Column="1" Grid.Row="5" BorderBrush="Black" BorderThickness="0.5"/>
<Border Grid.Column="2" Grid.Row="5" BorderBrush="Black" BorderThickness="0.5"/>
<Border Grid.Column="3" Grid.Row="5" BorderBrush="Black" BorderThickness="0.5"/>
<Border Grid.Column="4" Grid.Row="5" BorderBrush="Black" BorderThickness="0.5"/>
<Border Grid.Column="5" Grid.Row="5" BorderBrush="Black" BorderThickness="0.5"/>
<Border Grid.Column="6" Grid.Row="5" BorderBrush="Black" BorderThickness="0.5"/>
<Border Grid.Column="0" Grid.Row="6" BorderBrush="Black" BorderThickness="0.5"/>
<Border Grid.Column="1" Grid.Row="6" BorderBrush="Black" BorderThickness="0.5"/>
<Border Grid.Column="2" Grid.Row="6" BorderBrush="Black" BorderThickness="0.5"/>
<Border Grid.Column="3" Grid.Row="6" BorderBrush="Black" BorderThickness="0.5"/>
<Border Grid.Column="4" Grid.Row="6" BorderBrush="Black" BorderThickness="0.5"/>
<Border Grid.Column="5" Grid.Row="6" BorderBrush="Black" BorderThickness="0.5"/>
<Border Grid.Column="6" Grid.Row="6" BorderBrush="Black" BorderThickness="0.5"/>
<Canvas Name="Canvas00" Grid.Column="0" Grid.Row="2"/>
<Canvas Name="Canvas10" Grid.Column="1" Grid.Row="2"/>
<Canvas Name="Canvas20" Grid.Column="2" Grid.Row="2"/>
<Canvas Name="Canvas30" Grid.Column="3" Grid.Row="2"/>
<Canvas Name="Canvas40" Grid.Column="4" Grid.Row="2"/>
<Canvas Name="Canvas50" Grid.Column="5" Grid.Row="2"/>
<Canvas Name="Canvas60" Grid.Column="6" Grid.Row="2"/>
<Canvas Name="Canvas01" Grid.Column="0" Grid.Row="3"/>
<Canvas Name="Canvas11" Grid.Column="1" Grid.Row="3"/>
<Canvas Name="Canvas21" Grid.Column="2" Grid.Row="3"/>
<Canvas Name="Canvas31" Grid.Column="3" Grid.Row="3"/>
<Canvas Name="Canvas41" Grid.Column="4" Grid.Row="3"/>
<Canvas Name="Canvas51" Grid.Column="5" Grid.Row="3"/>
<Canvas Name="Canvas61" Grid.Column="6" Grid.Row="3"/>
<Canvas Name="Canvas02" Grid.Column="0" Grid.Row="4"/>
<Canvas Name="Canvas12" Grid.Column="1" Grid.Row="4"/>
<Canvas Name="Canvas22" Grid.Column="2" Grid.Row="4"/>
<Canvas Name="Canvas32" Grid.Column="3" Grid.Row="4"/>
<Canvas Name="Canvas42" Grid.Column="4" Grid.Row="4"/>
<Canvas Name="Canvas52" Grid.Column="5" Grid.Row="4"/>
<Canvas Name="Canvas62" Grid.Column="6" Grid.Row="4"/>
<Canvas Name="Canvas03" Grid.Column="0" Grid.Row="5"/>
<Canvas Name="Canvas13" Grid.Column="1" Grid.Row="5"/>
<Canvas Name="Canvas23" Grid.Column="2" Grid.Row="5"/>
<Canvas Name="Canvas33" Grid.Column="3" Grid.Row="5"/>
<Canvas Name="Canvas43" Grid.Column="4" Grid.Row="5"/>
<Canvas Name="Canvas53" Grid.Column="5" Grid.Row="5"/>
<Canvas Name="Canvas63" Grid.Column="6" Grid.Row="5"/>
<Canvas Name="Canvas04" Grid.Column="0" Grid.Row="6"/>
<Canvas Name="Canvas14" Grid.Column="1" Grid.Row="6"/>
<Canvas Name="Canvas24" Grid.Column="2" Grid.Row="6"/>
<Canvas Name="Canvas34" Grid.Column="3" Grid.Row="6"/>
<Canvas Name="Canvas44" Grid.Column="4" Grid.Row="6"/>
<Canvas Name="Canvas54" Grid.Column="5" Grid.Row="6"/>
<Canvas Name="Canvas64" Grid.Column="6" Grid.Row="6" />
<Label FontSize="10" HorizontalContentAlignment="Center" Name="label1" VerticalContentAlignment="Center" Grid.Column="0" Grid.Row="1">
Sunday
</Label>
<Label FontSize="10" HorizontalContentAlignment="Center" Name="label2" VerticalContentAlignment="Center" Grid.Column="1" Grid.Row="1">
Monday
</Label>
<Label FontSize="10" HorizontalContentAlignment="Center" Name="label3" VerticalContentAlignment="Center" Grid.Column="2" Grid.Row="1">
Tuesday
</Label>
<Label FontSize="10" HorizontalContentAlignment="Center" Name="label4" VerticalContentAlignment="Center" Grid.Column="3" Grid.Row="1">
Wensday
</Label>
<Label FontSize="10" HorizontalContentAlignment="Center" Name="label5" VerticalContentAlignment="Center" Grid.Column="4" Grid.Row="1">
Thursday
</Label>
<Label FontSize="10" HorizontalContentAlignment="Center" Name="label6" VerticalContentAlignment="Center" Grid.Column="5" Grid.Row="1">
Friday
</Label>
<Label FontSize="10" HorizontalContentAlignment="Center" Name="label7" VerticalContentAlignment="Center" Grid.Column="6" Grid.Row="1">
Saturday
</Label>
<Label FontSize="14" HorizontalContentAlignment="Center" Name="lblMonthYear" VerticalContentAlignment="Center" Grid.ColumnSpan="8" FontFamily="Comic Sans MS" FontWeight="Black">
July 2008
</Label>
<Button Name="btnSubtractYear" Grid.Column="0" Click="btnSubtractYear_Click"><< Year</Button>
<Button Name="btnSubtractMonth" Grid.Column="1" Click="btnSubtractMonth_Click"><< Month</Button>
<Button Name="btnAddMonth" Grid.Column ="5" Click="btnAddMonth_Click">Month >></Button>
<Button Name="btnAddYear" Grid.Column="6" Click="btnAddYear_Click">Year >></Button>
</Grid>
</UserControl>
As you can see ive got "Canvas" objects within the grid, but im not sure if thats the right control for what i need it to do.
at this point i need to be able to some painting on it from the code behind, depending on which month & year is selected the day numbers need to be drawn in the right blocks, but i cant seem to figure out how to do that... my brain is still thinking in GDI
any help would be appreciated
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
you.suck = (you.passion != Programming)
|
|
|
|
|
WRAP PANEL ALERT!!!!
Have a look into the wrap panel. Also you could:
<Style x:Name="CalCellBorder" TargetType="{x:Type Border}">
<Setter Property="BorderBrush" Value="Black"/>
<Setter Property="BorderThickness" Value="0.5" />
<Style>
Then, if the style is placed inside:
<UserControl.Resources>
</UserControl.Resources>
Such As:
<UserControl.Resources>
<Style x:Name="CalCellBorder" TargetType="{x:Type Border}">
<Setter Property="BorderBrush" Value="Black"/>
<Setter Property="BorderThickness" Value="0.5" />
<Style>
</UserControl.Resources>
You can then do:
<Border Grid.Column="5" Grid.Row="5" Style="{StaticResource CalCellBorder}"/>
|
|
|
|
|
The first thing that jumped out at me is that you are not nesting the controls. The way it stands now, the Canvas and Label elements will end up on top of instead of inside the Borders in the same grid cell. My guess is that you are using the Rectangles as a background color for certain cells; if so, you can use the Background property of the Border instead.
Personally, I would use the lighter-weight TextBlock instead of Label (which unlike its Forms cousin can show a wide range of content) if all you will show is text.
As for the using a Canvas, if all you want to do is put the date in the cell, I would again use a TextBlock inside the Border and change the Text property to match the day you need.
|
|
|
|
|
Hi All,
Is this possible? You have a button in the UI with its content property set as:
XAML:
<Button x:Name="btn" Content="Original Value" />
Then in your C# code you change that Content property to be something else like:
CS:
btn.Content = "New Value";
Can you subsequently access the original value set in XAML without the need for doing something like this in more C#:
btn.Content = "Original Value";
I can't even seem to find the array of _effectiveValues for a button in Visual Studio ...
|
|
|
|
|
They both count as the local value so I think your better off keeping track of the original value yourself. If you set the xaml value using a style you could do it but that seemed to be an ugly hack.
|
|
|
|
|
Using an attached property to store the original value works quite well. You probably wouldn't want to declare the attached property in a window as I have done.
<Button x:Name="b" Click="b_Click" local:Window1.OriginalContent="OriginalValue" />
void b_Click(object sender, RoutedEventArgs e)
{
var newValue = "New Value";
var original = GetOriginalContent(b);
b.Content = b.Content.Equals(newValue) ? original : newValue;
}
#region OriginalContent Attached Property
public static readonly DependencyProperty OriginalContentProperty = DependencyProperty.RegisterAttached("OriginalContent", typeof (object), typeof (Window1), new UIPropertyMetadata(Changed));
private static void Changed(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
((ContentControl) d).Content = e.NewValue;
}
public static object GetOriginalContent(DependencyObject d)
{
return d.GetValue(OriginalContentProperty);
}
public static void SetOriginalContent(DependencyObject d, object value)
{
d.SetValue(OriginalContentProperty, value);
}
#endregion
|
|
|
|
|
Interesting idea ...
When I get to work in a couple of hours I'll dig out the code that I used to get at the _effectiveValues and see if anything can be done with that. I'll post it here as well.
Urgh, I feel sick just thinking about it!!
Thanks for this Dave.
|
|
|
|
|
Indeed, I was looking through the results of the LocalValueEnumerator and trying ReadLocalValue etc ...
I've had lots of fun in the past coding round the _effectiveValues array. Its really not pretty code at all. According to one thing I read this whole area of WPF is 'unfinished'. I just hope that in the next version some of this stuff is 'fixed' or 'completed'.
|
|
|
|
|
I've just tried this:
object _buttonContent = btnLoadData.ReadLocalValue(ContentProperty);
if (_buttonContent != DependencyProperty.UnsetValue && _buttonContent != null)
{
Type tx = _buttonContent.GetType();
PropertyInfo pinfo = tx.GetProperty("Content");
if (pinfo != null)
{
object objPropertyValue = pinfo.GetValue(_buttonContent, null);
string BtnContent = objPropertyValue as string;
}
}
No luck, as you say they both count as local values. There doesn't seem to be any way of 're-reading' the XAML Content="Original Value" ...
That just seems absolutely NUTS to me ... it must be doable ... surely ...
|
|
|
|
|
Hi,
i'm quite nobbie with C# and WPF but it seems as very interesting to me...
here is my question, how can i make custom main frame look with wpf
i know for the property "WindowStyle..." but i need to change default style...
is ti possible to override the default style form and how?
the reason is simple, i want my application to look the same on every windows version with every
|
|
|
|
|
You make so the window has no border and then you can WPF elements to alter the appearance of the window. If you want to make the windows look the same: create one window with the appearance you want, then make the other windows inherited from the original one.
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my Blog
|
|
|
|
|
Ok,
how can i make all other elements look the same
like chack boxes, text fields, dropDown lists etc ???
|
|
|
|
|
You can define styles for the controls that will be automatically applied. If you want to do this, I would expect that you have Blend installed - it makes things easier for you.
|
|
|
|
|
i'm searching all around codeproject for some article about exactly that but i can't find it :$
if you know any, could you provide me with link please
|
|
|
|
|
Do an article search for articles by Josh Smith or Sacha Barber.
|
|
|
|
|
i already found some of their articles,
thank you..
however, it's seemed to me that they are too much concrete about topics
but i'll try to look deeper in to WPF on MSDN
thank you
|
|
|
|