|
|
You may want to consider using a Grid inside a ScrollViewer.
The Grid provides a very easy way to have two rows per hour like the picture and then you can add columns as required for each of the actual schedules.
The wrapping ScrollViewer allows you to contain the grid in a certain amount of space and then have the user scroll up and down.
Then add child border controls that span the required number of Grid.Rows. For example, if you have a 2 hour appointment then you would add that border control and have its RowSpan property set to 4. You can style the border control any way you want.
You can then add a TextBlock that displays the text of the appointment. If you have multi-line appoinments you can use some cool features of WPF inside your TextBlock to display formatted text.
Check this very simple example out:
<TextBlock>
<Run FontWeight="Bold">Mole</Run> loves the managed heap<LineBreak />
I hope this helps you get started!
</TextBlock>
modified 27-Feb-21 21:01pm.
|
|
|
|
|
Hi karl
Thanks a lot for your advise.I will try it out
|
|
|
|
|
|
Hi Ron
Thanks for the link.I will try to use it.
|
|
|
|
|
Hi All,
Not been around here for a few weeks as I've just become a Dad!!
Anyway ... I'm just looking for a few pointers and wotnot on how best to approach this task. I'm currently starting work on my second WPF application for my employer and one thing I want to do is before moving either project forward any more is to standardise the look and feel between the two (and obviously any future applications). Also this means that other developers here can just plug in a set of standard styles and get to work on the logic rather than worrying about the look and feel (my job largely!).
The most obvious way would be to have a 'Styles' project in a separate Visual Source Safe project with a <controlname>.xaml file for each control (like combo.xaml, textbox.xaml etc) ... or just one large style.xaml containing all our style code (this could however become a very large single file!).
What I'm wondering is before I start on this as a project in its own right is there a better way than just having xaml files? Would it make sense to build a style.dll that could be plugged into any application that would only provide styles and control templates for consumption by other developers?
We are using the Infragistics controls here and they provide a similar approach whereby we could build theme.dll's for our users to then select a theme for their instance of our application. I think that from a consumption point of view that is a much neater solution.
Thanks in advance for any input.
Jammer
Going where everyone here has gone before!
My Blog
|
|
|
|
|
First of all, congratulations. Boy or girl?
Secondly, we use a set of themes and load them in dynamically. The advantage of this is that we can change/upgrade applications merely by changing the themes. It's a convenient way to "freshen" up an application without having to manage lots of different codebases.
|
|
|
|
|
Hey Pete,
Its a lil girl! So cool ...
How do you store all the theme code though? Are you using DLLs that are distributed with your applications?
How do you manage that within a multi developer environment?
Jammer
Going where everyone here has gone before!
My Blog
|
|
|
|
|
Jammer wrote: Are you using DLLs that are distributed with your applications?
Yup.
Jammer wrote: How do you manage that within a multi developer environment?
By having a designer come up with the themes.
|
|
|
|
|
Ahh ok ... theme DLL's it is then. I thought that would be the best solution to this particular issue.
Thanks chap.
Jammer
Going where everyone here has gone before!
My Blog
|
|
|
|
|
Thanks for this Pete, I've pretty much got a working style.dll done now. Lots of tweaking to do and wotnot but this is indeed a seriously neat solution.
Just a quick one, do you have any neat tricks that you found on your journey down this route?
Jammer
Going where everyone here has gone before!
My Blog
|
|
|
|
|
Hi,
I am trying to add some images to a listbox as described in Josh Smith's excellent article <a href="http://www.codeproject.com/KB/WPF/CustomListBoxLayoutInWPF.aspx">here</a>.
The only twist is that I need to bind to a list of BitmapImages that are created using a MemoryStream.
The images are being read from a database and I don't want to have to save them locally before showing them in the listbox.
I am not getting any errors - there are just no images being displayed.
I have taken the XAML entirely as is from Josh's article (I did try changing the Image binding from UriSource to StreamSource but that didn't work).
I'm pretty new to WPF so I'm probably doing something something really stupid, can anyone suggest what it is?
<code>
public static List<BitmapImage> GetProductImages() {
List<BitmapImage> images = new List<BitmapImage>();
using (SqlConnection cn = new SqlConnection(cnString)) {
string sql = "SELECT Top 10 ProductImage From Products WHERE NOT (ProductImage IS NULL)";
SqlCommand cmd = new SqlCommand(sql);
cmd.Connection = cn;
cmd.Connection.Open();
SqlDataReader reader = cmd.ExecuteReader();
while (reader.Read()) {
byte[] productImage = null;
productImage = (byte[])reader["ProductImage"];
if (productImage != null) {
System.IO.MemoryStream ms = new System.IO.MemoryStream(productImage);
BitmapImage bm = new BitmapImage();
bm.BeginInit();
bm.StreamSource = ms;
bm.EndInit();
images.Add(bm);
}
}
cmd.Connection.Close();
}
return images;
}
</code>
Thanks very much,
dlarkin77
Edit: I don't know why that link doesn't appear as a clickable link or why the code isn't in a code block. Sorry about that!
<div class="ForumMod">modified on Wednesday, April 23, 2008 11:46 </div>
|
|
|
|
|
|
Hi,
Thanks for that tip.
The memory stream does indeed contain data. For testing purposes I've used the stream to save the image data as a file locally and then used this file to create the BitmapImage and that works fine. Can you suggest anything else?
Thanks very much,
dlarkin77
|
|
|
|
|
Did you check out the two posts? They contain sample code for getting this to work. I'm sure it's something very simple since you are 98% there.
I'll try and write a sample, ( Karl does VB.NET but will be simple to translate or read ) tonight and post it.
modified 27-Feb-21 21:01pm.
|
|
|
|
|
If you step through the code, what do you see at the line bm.StreamSource = ms ? Before you allocate the source, try setting ms.Position = 0; Alternatively, you can use ms.Seek(0, SeekOrigin.Begin);
-- Edit. The behaviour you are seeing is because the position of the pointer in the MemoryStream is pointing to the end when you have loaded it. You need to reset it back to the start before you can use it.
modified on Wednesday, April 23, 2008 5:30 PM
|
|
|
|
|
Hi,
Pete:
I have tried as you suggested but still no joy. No doubt I'm doing something really stupid so I'll post the code that I use.
This is the code I use to get my list of BitmapImages:
private void Window_Loaded(object sender, RoutedEventArgs e) {
List<BitmapImage> images = GetProductImages();
lstProductImages.ItemsSource = images;
}
private List<BitmapImage> GetProductImages() {
List<BitmapImage> images = new List<BitmapImage>();
using (SqlConnection cn = new SqlConnection(cnString)) {
string sql = "SELECT Top 10 ProductImage From Products WHERE NOT (ProductImage IS NULL)";
SqlCommand cmd = new SqlCommand(sql);
cmd.Connection = cn;
cmd.Connection.Open();
SqlDataReader reader = cmd.ExecuteReader();
while (reader.Read()) {
byte[] productImage = null;
productImage = (byte[])reader["ProductImage"];
using (MemoryStream ms = new MemoryStream(productImage)) {
//ms.Seek(0, SeekOrigin.Begin);
ms.Position = 0;
BitmapImage bm = new BitmapImage();
bm.BeginInit();
//bm.CacheOption = BitmapCacheOption.OnLoad;
bm.StreamSource = ms;
bm.EndInit();
ms.Close();
images.Add(bm);
}
}
cmd.Connection.Close();
}
return images;
}
This is the XAML for the listbox:
<Window.Resources>
<Style TargetType="{x:Type ListBox}">
<Setter Property="ItemTemplate">
<Setter.Value>
<DataTemplate>
<Border BorderBrush="Black" BorderThickness="4" CornerRadius="5" Margin="6">
<!--<Image
Source="{Binding Path=UriSource}"
Stretch="Fill"
Width="100" Height="120"/>-->
<Image
Source="{Binding Path=StreamSource}"
Stretch="Fill"
Width="100" Height="120"/>
</Border>
</DataTemplate>
</Setter.Value>
</Setter>
<Setter Property="ItemsPanel">
<Setter.Value>
<ItemsPanelTemplate>
<WrapPanel />
</ItemsPanelTemplate>
</Setter.Value>
</Setter>
<Setter
Property="ScrollViewer.HorizontalScrollBarVisibility"
Value="Disabled"
/>
</Style>
</Window.Resources>
<Grid>
<ListBox Name="lstProductImages"/>
</Grid>
Does anything obvious jump out at you?
Karl:
I've looked at both of those sites and played around with what they suggested to no avail.
Thanks very much,
dlarkin77
|
|
|
|
|
Hi,
I need compelete defination about WPF. Kindly give reference to download said information.
Thank you
(Riaz)
|
|
|
|
|
|
|
How to set mouse position? Something opposite to Mouse.GetPosition(container)
Thanks for help
|
|
|
|
|
Off the top of my head (and without firing up Visual Studio to check) I believe you would use Cursor.Position = new Point(x, y); .
|
|
|
|
|
So fire up VS and see that ur answer is silly
|
|
|
|
|
Yoyosch wrote: So fire up VS and see that ur answer is silly
Nope. I just ran it and it worked fine for me. Have you tried it?
|
|
|
|
|
Of course. This works in WinForms but not in WPF
|
|
|
|