|
Can the dreaded nullable combo-box be created in WPF. Of course with all the databinding enabled etc?
Seriously, I'm wondering why it hasn't already been done since this was a huge bug-bear with Windows Forms.
|
|
|
|
|
Ed.Poore wrote: Can the dreaded nullable combo-box be created in WPF.
Ed,
Dumb question. What is the dreaded nullable combo-box?
modified 27-Feb-21 21:01pm.
|
|
|
|
|
Not a dumb question although a quick Google would have given you the idea. Imagine any field where you want to select an item for a relationship in a drop-down or nothing.
E.g. you're assigning a bug to a user in your database. You use LINQ or whatever to pull the users from the database, and these are bound to the combobox so you get a list of all the users. But it should also have (None) or something similar so that if you select that item then the relationship is set to null.
There's been no easy workaround this problem in WinForms so hopefully the magic that is WPF would be able to do it
|
|
|
|
|
You can add the extra row in the data in your business layer or data layer, or simply extend the combobox to function like the ASP.NET dropdown control that has this built in.
modified 27-Feb-21 21:01pm.
|
|
|
|
|
Karl Shifflett wrote: You can add the extra row in the data in your business layer or data layer
That's those hacks I mentioned. Not really a good design.
Karl Shifflett wrote: extend the combobox to function like the ASP.NET dropdown control that has this built in
I wanted to see some code
|
|
|
|
|
2 thoughts. 1 - do this in exactly the way that Karl suggested and create your own control, or 2 - use an Extension method that would look something like this:
public static void NullableDataSource<T>(this ComboBox source, IList<T> binding)
where T : class, new()
{
if (binding != null)
{
binding.Insert(0, "<Null>");
}
source.DataSource = binding;
} I've not tried this out, I'm just typing the code off the top of my head, but there's no reason that this (or something like this) wouldn't work.
|
|
|
|
|
It does work, on the surface. However if you try and access the lists through other methods then it messes up (i.e. through indicies).
I was thinking that there'd be an ice elegant way to create a combo box in WPF which allows it to be set as nullable, rather than having to modify the underlying data.
Perhaps creating a new items template thingy and inserting a control there which if selected is null. I.e. the underlying datasource is not modified at all.
I'll see what I can do when I get the chance. Just wondering if someone had come up with a solution already.
|
|
|
|
|
Hi All,
I'm just adding in ToolTips to a chart I'm building in WPF. The TargetType is set to {x:Type ToolTip} and the style definition is placed in the <usercontrol.resources> section of the XAML.
Running the application and navigating to the screen with the chart in works ok (no compile error) but the tooltip is not styled as per the definition. Going into Blend and looking at the UserContol is ok but when I click on the [Edit Resource] button for [System.Windows.Controls.ToolTip] resource I get the following error:
'ToolTip' cannot have a logical or visual parent.
Any ideas would be great.
Jammer
Going where everyone here has gone before!
My Blog
|
|
|
|
|
Can you post the XAML?
modified 27-Feb-21 21:01pm.
|
|
|
|
|
Hi Karl,
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:igCA="http://infragistics.com/Chart"
xmlns ="http://schemas.microsoft.com/expression/blend/2006"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
x:Class="Occam.ZebraDemo.WPFWindows.Zebra3DPieChart"
x:Name="ZebraCleaningChartControl"
Width="605" Height="454">
<UserControl.Resources>
<!-- ToolTip Style -->
<Style TargetType="{x:Type ToolTip}">
<Setter Property="Background" Value="#FF0000" />
<Setter Property="FontFamily" Value="Segoe UI" />
<Setter Property="FontSize" Value="12" />
<Setter Property="FontWeight" Value="Normal" />
<Setter Property="Foreground" Value="#FFFFFF" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToolTip}">
<Border CornerRadius="4" Background="Transparent">
<ContentPresenter Margin="6,4,6,4" />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</UserControl.Resources>
<Grid x:Name="LayoutRoot">
<igCA:XamChart Margin="0,0,0,0" Name="ZebraCleaningChart" View3D="True" Style="{DynamicResource Zebra_XamChartRoyalVelvet}" BorderThickness="0,0,0,0">
<igCA:XamChart.Legend>
<igCA:Legend Visible="False" />
</igCA:XamChart.Legend>
<!-- Data Points and Chart Parameters -->
<igCA:XamChart.Series>
<igCA:Series Label="Cleaning Results" ChartType="Pie">
<igCA:Series.DataPoints>
<igCA:DataPoint Label="Good Records" Value="30" />
<igCA:DataPoint Label="Bad Records" Value="10" />
<igCA:DataPoint Label="Unknown" Value="20" />
</igCA:Series.DataPoints>
</igCA:Series>
</igCA:XamChart.Series>
<!-- 3D Transform (Rotation etc ...) -->
<igCA:XamChart.Transform3D>
<Transform3DGroup>
<TranslateTransform3D OffsetX="0" OffsetY="0" OffsetZ="0"/>
<ScaleTransform3D ScaleX="1" ScaleY="1.0000000000000002" ScaleZ="1.0000000000000002"/>
<RotateTransform3D d:EulerAngles="-28.387969869694,9.27192578600399,-3.5230603833372">
<RotateTransform3D.Rotation>
<AxisAngleRotation3D Angle="29.766" Axis="-0.942,0.334,-0.039"/>
</RotateTransform3D.Rotation>
</RotateTransform3D>
<TranslateTransform3D OffsetX="0" OffsetY="0" OffsetZ="0"/>
<TranslateTransform3D OffsetX="0" OffsetY="0" OffsetZ="0"/>
</Transform3DGroup>
</igCA:XamChart.Transform3D>
</igCA:XamChart>
</Grid>
</UserControl>
Jammer
Going where everyone here has gone before!
My Blog
|
|
|
|
|
Jammer,
Take a close look at the colors. I added the alpha channel to each of your hex colors.
The Background of the Border was Transparent, I made it Black and the ToolTip now shows up.
Not sure why Blend blows up. I'm using Blend 2.5, got the same thing. I would send your example to the Blend team.
The below template works fine and shows the tooltip at run-time.
<UserControl.Resources>
<!-- ToolTip Style -->
<Style TargetType="{x:Type ToolTip}">
<Setter Property="Background" Value="#FF000000" />
<Setter Property="FontFamily" Value="Segoe UI" />
<Setter Property="FontSize" Value="12" />
<Setter Property="FontWeight" Value="Normal" />
<Setter Property="Foreground" Value="#FFFFFFFF" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToolTip}">
<Border CornerRadius="4" Background="#FF000000" >
<ContentPresenter />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</UserControl.Resources>
modified 27-Feb-21 21:01pm.
|
|
|
|
|
Ahhh, ok.
I've just amended my code to reflect the changes you detail and my ToolTip still isn't applying the styling.
My tooltip was always showing up just not with the style template applied to the tooltip.
This is really frustrating at the moment.
Thanks for the tips ... will keep on trying to get this working. I'm kida running out of time trying to get a simple tooltip running properly! feck!
Jammer
Going where everyone here has gone before!
My Blog
|
|
|
|
|
I'm thinking that the error blend is throwing is the reason why this style doesn't get applied at run-time ...
I've also tried moving this ToolTip definition into my applications main dictionary xaml file and its still ignored ...
Jammer
Going where everyone here has gone before!
My Blog
|
|
|
|
|
Hi Karl,
Any ideas on this? All I can get my tooltip to do is this:
http://www.jammer.biz/images/wpf/tooltip.png[^]
Its just completely ignoring the style. From looking at examples on the web I'm doing *exactly* the same thing (but in a usercontrol) and its failing to style ... I just can't work this out at all.
Could it be a settings conflict in the xaml? Maybe something in my dictionary is conflicting? Would that be highlighted at compile time?
Jammer
Going where everyone here has gone before!
My Blog
|
|
|
|
|
Just not sure. That tooltip I sent worked fine in a quick application I did.
Is the Infragistics control styling the ToolTip?
Break out Mole or Snoop and see if they have styled the ToolTip. If they style the ToolTip, it will override your styling.
You can also post on Infragistics Support forum and see what they say.
modified 27-Feb-21 21:01pm.
|
|
|
|
|
Indeed ... the style code works as designed. I added it into the default dictionary for the application and its styling every other tooltip in the interface as expected. And some of those are in other usercontrols so that's not the issue.
I'm going to delve in with mole tomorrow and investigate some more.
I have a priority support contract with Infragistics and I've emailed them to query this as well. The Infragistics stuff is really great.
Odd little problem I have here I think!
Jammer
Going where everyone here has gone before!
My Blog
|
|
|
|
|
Its been tracked down to some odd behaviour with the 3D chart. What I'm seeing isn't a tooltip ... its a textblock!
Jammer
Going where everyone here has gone before!
My Blog
|
|
|
|
|
Hi All,
I just took the plunge ... I've enabled AA under WinXP.
I'm producing a new WPF application using some controls and charting components from Infragistics. So far all is going really well with these controls. The only issue I had was the aliasing on the 3D content.
I'm just posting here to find out if anyone has had any negative experiences with using the XP AA with WPF.
We are currently doing our own investigations into potential problems like OS stability etc ... We need to do lots more as we are potentially going to offer a checkbox during installation that will also switch AA on for XP machine when our application is installed. Obviously we want to cover any and all eventualities upfront before making such an option available to end users.
Just for information, this is not going to be a 'general realease' application its business to business stuff with a small user base and a large price tag meaning that we will also be making a very explicit minimum specification for the machine that will run this software. ie: new and powerful ...
So far I've not seen *any* problems on my machine during development with XP AA switched on which is encouraging.
Also isn't this going to be part of the fabled XP SP3??
Cheers,
Jammer
Going where everyone here has gone before!
|
|
|
|
|
Jammer,
Dumb question to be sure; what is AA?
BTW: I sent all your information and questions/comments to the Blend Team last night.
modified 27-Feb-21 21:01pm.
|
|
|
|
|
Hey Karl,
That is great news! I hope they find them constructive/useful. Would be great to know what they think.
AA = anti aliasing ... I've just uploaded two example graphic files of my charts to my web server.
this first link show you a version of the chart with NO XP anti aliasing applied.
http://www.jammer.biz/images/wpf/chartalias.png[^]
This next link shows you the same chart (well rotated slightly) WITH anti aliasing.
http://www.jammer.biz/images/wpf/chartantialias.png[^]
As you can see from a UI point of view the second example is head and shoulders better than the aliased version. So I'm currently testing the water to see if I encounter any horrible errors or stability issues whilst using the XP AA.
Cheers,
Jammer
Going where everyone here has gone before!
|
|
|
|
|
Fantasic difference. Very nice chart too.
OK, another dumb question. How did you turn off AA on XP? Is this done in the video card software settings?
modified 27-Feb-21 21:01pm.
|
|
|
|
|
Actually its a question of turning ON anti alias under XP as its default is turned off ... according to Microsoft as it can cause stability issues when using the XDDM drivers (as I understand it XDDM is the format of video drivers used by WinXP)
In order to turn it on you need to add in keys to the registry here:
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Avalon.Graphics]
"MaxMultisampleType"=dword:00000004
"EnableDebugControl"=dword:00000001
By default the Avalon.Graphics key doesn't even exist in an XP registry.
Jammer
Going where everyone here has gone before!
|
|
|
|
|
Wow, I'm learning something new each day!
I've always had high end graphics cards (nVidia) in all my systems and thought the GPU and drives took care of all of this.
I'll do some testing this weekend and see what comes up.
Thank you!!
modified 27-Feb-21 21:01pm.
|
|
|
|
|
Heh heh ... Karl, try being me on this forum at the moment! Learning C# after 10 years of FoxPro hurts, believe me! I'm learning something new about 3 times a minute!! Some seriously knowledgeable folks around here such as yourself.
I'll say it again ... mole ... nuff said.
Anyway, anything you do find out this weekend would be seriously good to know.
As I understand it the only XP native anti aliasing that is available as a windows config option is the Font Smoothing / Clear Type stuff.
When you get into the realms of nVidia / ATI things I think it really depends on how the tech talking to it is configured rather than it 'just using' the GPU and its inbuilt feature set.
For instance I had a Quad core Xeon machine here that I develop on and it has a pretty hefty nVidia Quadro FX570 graphics card. Earlier when I first enabled the XP AA I also changed some of the nVidea 3D settings (stupid thing to do) when I then rebooted and started looking at some of the WPF stuff a lot of the 2D elements looked terrible even thought the 3D stuff looked great. I had to go and change the nVidia settings back to get the 2D & 3D stuff looking good.
Its more of an issue of interaction between the two rather than a set it and forget it thing on the video card alone.
I'm no graphics code man at all but these are a few things I've learned / noticed.
I just don't like having spent all this cash on the Infragistics controls to then see all the pixels in their squarey glory!
Jammer
Going where everyone here has gone before!
|
|
|
|
|
I'll give this all a go this weekend. I'll compare my XP and Vista results.
My Vista system is SUPER high end across the board. The XP system is very good so it will be nice to compare them with the standard settings and see what goes on.
Now that I'm thinking about it, the nVidia software on my XP machine does have the ability to AA in their 3D settings. I currently have it turned on too.
modified 27-Feb-21 21:01pm.
|
|
|
|