|
Sorry, I should have given more info. Here's what I have so far:
<Border Grid.Row="1"
Margin="0,20,0,20"
VerticalAlignment="Center"
BorderBrush="Transparent"
Height="250">
<pre>
<Border.Effect>
<DropShadowEffect Color="LightGray"
ShadowDepth="7"
Direction="90"/>
</Border.Effect>
This puts the drop shadow along the top. I'd like it both at the top and bottom
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
Try setting the ShadowDepth to 0 and playing with the BlurRadius instead.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I'm creating a theme with a base style for all controls:
<FontFamily x:Key="Font.Family.Default">Segoe UI</FontFamily>
<sys:Double x:Key="Font.Size.Header1">18</sys:Double>
<sys:Double x:Key="Font.Size.Header2">16</sys:Double>
<sys:Double x:Key="Font.Size.Header3">14</sys:Double>
<sys:Double x:Key="Font.Size.Normal">12</sys:Double>
<SolidColorBrush x:Key="TextBlock.Static.Background" Color="Transparent"/>
<SolidColorBrush x:Key="TextBlock.Static.Foreground" Color="DarkGray"/>
<Style x:Key="ControlBase" TargetType="{x:Type Control}">
<Setter Property="Control.FontSize" Value="{StaticResource Font.Size.Normal}"/>
<Setter Property="Control.FontFamily" Value="{StaticResource Font.Family.Default}"/>
<Setter Property="Control.HorizontalAlignment" Value="Center"/>
<Setter Property="Control.VerticalAlignment" Value="Center"/>
</Style>
<Style TargetType="{x:Type TextBlock}"
BasedOn="{StaticResource ControlBase}">
<Setter Property="Background" Value="{StaticResource TextBlock.Static.Background}"/>
<Setter Property="Foreground" Value="{StaticResource TextBlock.Static.Foreground}"/>
</Style>
I'm trying to use it like this:
<TextBlock Grid.Row="0"
Grid.Column="0"
Text="Test"
Margin="22,0,0,0"/>
The designer wont load, and when I run it I get
System.Windows.Markup.XamlParseException
Message='Initialization of 'System.Windows.Controls.TextBlock' threw an exception.' Line number '56' and line position '20'.
Inner Exception 1:
InvalidOperationException: Can only base on a Style with target type that is base type 'TextBlock'.
What's wrong here??
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
TextBlock doesn't inherit from class Control.
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
LOL - I knew that. Wow, I need to take a break.
Thanks
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
I have this in my theme file:
<Style TargetType="TextBlock">
<Setter Property="Foreground" Value="{DynamicResource textForegroundBrush}"/>
<Setter Property="FontSize" Value="14"/>
</Style>
Now, in a window I want to add additional settings
<Window.Resources>
<Style x:Key="headerTextStyle"
TargetType="TextBox">
<Setter Property="FontSize" Value="24"/>
</Style>
</Window.Resources>
Since the theme's style does not have a key, how do I base the window's style off the sstyle in the theme?
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
Try:
<Style x:Key="headerTextStyle" TargetType="TextBox" BasedOn="{StaticResource {x:Type TextBox}}">
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thanks, that did it.
I always thought using that would cause the child style to based off WPF's base style
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
Hi!
I've searched for a couple of hours here and in other forums and at GitHub but couldn't find an answer.
I have a XML file and can read it in a DataTable and show that in a DataGrid. But I want to edit cells/values in the DataGrid and write the corrected values back to the XML file. It's easy for me to write the corrections to the DataTable and back to the XML file but how can I do the edit in the DataGrid ???
What I have so far with VisualStudio 2022:
using ...
namespace Gewicht
{
public partial class MainWindow : Window
{
public string[] dbFile = { @"H:\Daten\C#WPF\Gewicht\GewichtDaten.xml", @"H:\Daten\C#WPF\Gewicht\GewichtDaten.xsd" };
public DataTable dbDataTbl = new DataTable();
public MainWindow()
{
InitializeComponent();
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
if (!System.IO.File.Exists(dbFile[0]) | !System.IO.File.Exists(dbFile[1]))
{
SystemSounds.Beep.Play();
MessageBox.Show("Die Datei" + Environment.NewLine + " " + dbFile[0] + Environment.NewLine + "und/oder" + Environment.NewLine + " " + dbFile[1] + Environment.NewLine + "fehlt." + Environment.NewLine + "Das Programm wird beendet.", "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
Environment.Exit(0);
}
DataGrid1.CanUserAddRows = false;
DataGrid1.CanUserDeleteRows = false;
OpenData();
}
private void DataGrid1_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
{
}
private void OpenData()
{
dbDataTbl.Columns.Clear();
dbDataTbl.Rows.Clear();
dbDataTbl = new DataTable("ich");
dbDataTbl.ReadXmlSchema(dbFile[1]);
dbDataTbl.ReadXml(dbFile[0]);
DataSet dataSet = new DataSet();
dataSet.ReadXml(dbFile[0]);
DataView dataView = new DataView(dataSet.Tables[0]);
DataGrid1.ItemsSource = dataView;
Style style = new Style();
style.TargetType = typeof(DataGridCell);
Setter setter = new Setter();
setter.Property = DataGridCell.ForegroundProperty;
setter.Value = Brushes.LightGray;
style.Setters.Add(setter);
DataGrid1.Columns[0].CellStyle = style;
style = new Style();
setter = new Setter();
setter.Property = DataGridCell.HorizontalContentAlignmentProperty;
setter.Value = HorizontalAlignment.Right;
DataGrid1.Columns[2].CellStyle = style;
}
}
}
What I also want:
- Data column 0 should be gray (done) and the values right aligned.
- Data column 2 should be right aligned and with number format "##0.0".
Thanks
|
|
|
|
|
|
I'm trying to figure out some alignment issues in one of my form.
Grid, containing stackpanels, containing grids. ...
It's an ItemTemplate, so I cannot see the design in Visual Studio, so I have to run and adjust the XAML and run again (some changes can be tested live, I know).
So, is there a way to see the bounded box around controls ?
I bodge something by wrapping controls inside Border and put a thickness of 1 for debugging.
But there must be a better way.
Thanks.
CI/CD = Continuous Impediment/Continuous Despair
|
|
|
|
|
|
Hi.
I have a request to change the look of our TogggleButton.
I'm not sure what to search for on the internet.
Instead of changing the background color when the TogggleButton is checked, I would need to have a line under it.
See imgur image : togglebutton - Album on Imgur
I know how to use ControlTemplates (with Storyboard and Coloranimation with the EnterActions and ExitActions) to change the background.
But I'm not sure how to do this for BorderThickness or if there is something better I could use.
Thanks for hints or tips or any "google search" I can do
CI/CD = Continuous Impediment/Continuous Despair
|
|
|
|
|
Use a one sided border:
<Border BorderThickness="0,0,0,2" BorderBrush="Black" >
<ToggleButton />
</Border>
Toggle the visibility of the border, the Brush (Transparent), or change the thickness - based on "Checked".
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
Just found out we already have an in-house style for that in one of our dependency.
Thanks.
CI/CD = Continuous Impediment/Continuous Despair
|
|
|
|
|
I'm not certain what I have to google for.
I have Drawing images in an resource file like this :
<DrawingImage x:Key="FindIcon"/>
<DrawingImage x:Key="SearchIcon"/>
I can use them like this :
<Image Source="{StaticResource FindIcon}"/>
<Image Source="{StaticResource SearchIcon}"/>
Now, I want to be able to bind the image source and conditionally choose the image in the Code-Behind.
<Image Source="{Binding ChooseIcon}"/>
I'm not certain how I reference the image in the code ?
Is this a DrawingImage ? How do I load it in the code ?
public DrawingImage ChooseIcon
{
get
{
if (useFindIcon)
{
return ???;
}
else if (useSearchIcon)
{
return ???;
}
}
}
Thanks.
Max.
CI/CD = Continuous Impediment/Continuous Despair
|
|
|
|
|
The view-model shouldn't really know anything about your resources.
I'd suggest having an enum to represent the icon you want to display. Bind the source to that enum, and use a converter to convert the value to the relevant image.
Eg:
public enum ChooseIcon
{
Find,
Search,
}
public class YourViewModel
{
private ChooseIcon _chooseIcon;
public ChooseIcon ChooseIcon
{
get { return _chooseIcon; }
set { SetProperty(ref _chooseIcon, value); }
}
}
public class ChooseIconConverter : IValueConverter
{
public ImageSource FindIcon { get; set; }
public ImageSource SearchIcon { get; set; }
public object Convert (object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
switch ((ChooseIcon)value)
{
case ChooseIcon.Find: return FindIcon;
case ChooseIcon.Search: return SearchIcon;
default: return null;
}
}
public object ConvertBack (object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return Binding.DoNothing;
}
}
<Window.Resources>
<local:ChooseIconConverter
x:Key="ChooseIconConverter"
FindIcon="{StaticResource FindIcon}"
SearchIcon="{StaticResource SearchIcon}"
/>
</Window.Resources>
...
<Image Source="{Binding ChooseIcon, Mode=OneWay, Converter={StaticResource ChooseIconConverter}}" />
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thanks.
Will look at that.
I also bodge a hack by having 2 Image tags and add a Visibility binding.
CI/CD = Continuous Impediment/Continuous Despair
|
|
|
|
|
Awesome, it's working.
CI/CD = Continuous Impediment/Continuous Despair
|
|
|
|
|
I have an app in which the user can create invoices. There is a lot of data on an invoice:
Jobs
Ship To Address
Builders
Foremen
Foreman Phone
Vendors
Vendor Locations
Vendor Contacts
Vendor Contact Email
Vendor Contact Phone
Delivery Method (Will Call or Delivery)
Delivery Date
For Will Call
Picked Up By (employee)
Picked Up By Email
Picked Up By Email
Picked Up Location (From Vendor Locations)
Items (The items on the PO)
Much of this is just lists. Right now, some dat is not retrieved until it's needed. For example, Vendor Locations are not retrieved until a Vendor is selected.
The problem is that it's getting slow. There's a lot of logic being run when list items are picked.
So, should I only load data when it's needed, or load all data first then run any logic, like the Vendor Location? In other words, get all Vendors and all Vendor Locations, and only load the locations in the client one the initial data load is done?
Thanks
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
Both. Your app should anticipate the user's intention by the parts they're accessing and start asynchronous loads into observable collections that get bound when a particular user control ("view") gets loaded.
And / or you need revised stored procs / data views / filtering.
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
I'm looking for a control that does the following.
When I do an action in my UI, I want to have a small window that slides in an out showing a small explanation text.
For example, I have a "copy" button that will put something on the clipboard.
I want to show a quick message that said "XYZ copied on the clipboard" the message will slide in and out of the main window.
I was looking at <popup> with an animation but I'm not sure it's what I want.
Or do you have a better alternative ?
Thanks.
CI/CD = Continuous Impediment/Continuous Despair
|
|
|
|
|
|
thanks, will have a look at it.
CI/CD = Continuous Impediment/Continuous Despair
|
|
|
|
|
it looks nice, even if it is a little bit "in your face".
Will experiment with look and feel.
Thanks again
CI/CD = Continuous Impediment/Continuous Despair
|
|
|
|