|
The fact it "looks" like a grid, doesn't mean you need to use a "DataGrid" control.
You haven't even established a "view port"; i.e. how many cells you expect to "see" at any one time.
Then you can start thinking in terms of "pages" (and virtualization; as has been already suggested).
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
Thanks. The number of cells visible is determined by the user and the monitor size, but roughly 30 by 30 say. However, it is a variable.
|
|
|
|
|
I'm using the WPF Toolkit PropertyGrid
I'd like to create a context menu on each property with Cut, Copy, Paste, Undo, and Reset. There doesn't seem to be any documentation at all, and I can't find any resources on this.
Has anyone done this that can help out?
Thanks
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
There's some limited documentation on the Xceed site: PropertyGrid Class | Xceed Toolkit Plus for WPF v3.6 Documentation[^]
But it's not great, and it's mixed in with documentation for the commercial "plus" version.
I can't find anything about creating a custom context menu for a property.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I've already see it
That's not documentation. That's an API. An API tells you WHAT it does, not HOW to do it.
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
Agreed - their documentation is sorely lacking.
It might be worth posting this question in their support forum as well:
Xceed Toolkit Plus for WPF – Xceed[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I created an Image button called MultiImageButton with 4 properties for Normal, Mouse Over, Disabled, and Pressed. I won't post the class code (unless you want me to ) because it works and isn't the problem. The class is in the Controls folder.
In the same project I created a style for it:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:System="clr-namespace:System;assembly=mscorlib"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:cctrls="clr-namespace:Controls"
mc:Ignorable="d">
<pre>
<!THE TEMPLATE>
<ControlTemplate x:Key="MultiImageButtonTemplate"
TargetType="{x:Type cctrls:MultiImageButton}">
<Grid x:Name="Grid">
<Border x:Name="Background"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="0"
Visibility="{Binding BorderVisibility, RelativeSource={RelativeSource TemplatedParent}}"/>
<StackPanel Orientation="Horizontal"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}">
<Image x:Name="ButtonImage"
Source="{Binding NormalImage, RelativeSource={RelativeSource TemplatedParent}}"
Height="{Binding ImageSize, RelativeSource={RelativeSource TemplatedParent}}"
Width="{Binding ImageSize, RelativeSource={RelativeSource TemplatedParent}}"
ToolTip="{TemplateBinding ToolTip}"/>
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
Margin="{TemplateBinding Padding}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
RecognizesAccessKey="True" />
</StackPanel>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="ButtonImage" Property="Source" Value="{Binding HoverImage, RelativeSource={RelativeSource TemplatedParent}}" />
</Trigger>
<Trigger Property="IsPressed" Value="true">
<Setter TargetName="ButtonImage" Property="Source" Value="{Binding PressedImage, RelativeSource={RelativeSource TemplatedParent}}" />
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter TargetName="ButtonImage" Property="Source" Value="{Binding DisabledImage, RelativeSource={RelativeSource TemplatedParent}}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<!IMAGE BUTTON BASE STYLE>
<Style x:Key="MultiImageButtonStyle"
TargetType="{x:Type cctrls:MultiImageButton}"
BasedOn="{StaticResource {x:Type cctrls:MultiImageButton}}">
<Setter Property="Cursor" Value="Hand"/>
<Setter Property="Template" Value="{StaticResource MultiImageButtonTemplate}" />
</Style>
<!NAV LEFT BUTTON STYLE>
<Style x:Key="NavLeftButtonStyleStyle"
TargetType="{x:Type cctrls:MultiImageButton}"
BasedOn="{StaticResource MultiImageButtonStyle}">
<Setter Property="ImageSize" Value="32"/>
<Setter Property="NormalImage" Value="/GenMarkDX.RemoteManagement.Common;component/Media/Images/arrow_left_normal.png"/>
<Setter Property="HoverImage" Value="/GenMarkDX.RemoteManagement.Common;component/Media/Images/arrow_left_mouseover.png"/>
<Setter Property="PressedImage" Value="/GenMarkDX.RemoteManagement.Common;component/Media/Images/arrow_left_normal.png"/>
<Setter Property="DisabledImage" Value="/GenMarkDX.RemoteManagement.Common;component/Media/Images/arrow_left_disabled.png"/>
</Style>
In a different project I added it to a window:
xmlns:cctrls="clr-namespace:Common.Controls;assembly=Common"
.
.
.
<cctrls:MultiImageButton Grid.Row="1"
Grid.Column="0"
Command="{Binding NavLeftCommand}"
Margin="5"
Style="{StaticResource NavLeftButtonStyleStyle}"/>
When I run this I get the error: "Cannot find resource named 'Common.Controls.MultiImageButton'. Resource names are case sensitive."
Again, the class with the button is in the same project as the style. There's no reason that I can see why the style shouldn't find the class. This works in a different app, just not here.
Anyone see what's wrong?
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
We declare our styles in the app.xaml as MergedDictionaries. It feels like you are just referencing the assembly CommonControls
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Assets/Styles/Brushes.xaml" />
They then become available as StaticResources, not sure if that helps or not.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I've got the following DataGridTemplateColumn with a UserControl as its DataTemplate. I can't get the binding right. I need it to bind to the grid's data. What am I doing wrong here?
<DataGrid.Columns>
<DataGridTemplateColumn Header="Value">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<ContentControl>
<ContentControl.Style>
<Style TargetType="ContentControl">
<Style.Triggers>
<DataTrigger Binding="{Binding PropertyType}" Value="{x:Static ca:PropertyType.Boolean}">
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
<ctrls:CheckBoxPropertyView IsCheckedValue="{Binding Value}"/> <==HERE
</DataTemplate>
</Setter.Value>
</Setter>
</DataTrigger>
</Style.Triggers>
</Style>
</ContentControl.Style>
</ContentControl>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
Bindings for value DataGridTemplateColumns don't show correctly in the designer intellisense, though they are binding to the ItemSource for your grid. It's an annoyance that I've learned to live with, as the values do bind correctly at run time.
That said, your style trigger is pretty mungy. Is there a terribly compelling reason that you can't do:
<DataGrid.Columns>
<DataGridTemplateColumn Header="Value">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<ctrls:CheckBoxPropertyView IsCheckedValue="{Binding Value}"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
|
|
|
|
|
Nathan Minier wrote: Is there a terribly compelling reason that you can't do:
There can be any number of UserControls. Each row will have a different one based on the PropertyType enum set in the DataTrigger
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
That would be a compelling reason!
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
|
|
|
|
|
I have this DataGrid:
<DataGrid Grid.Row="2"
Grid.Column="0"
Grid.ColumnSpan="2"
ItemsSource="{Binding Files}"
SelectedItem="{Binding SelectedFile}">
<DataGrid.Columns>
<DataGridCheckBoxColumn Header="Selected" Width="55" Binding="{Binding IsSelected, Mode=TwoWay}" IsReadOnly="{Binding IsFixed}" />
<DataGridTextColumn Header="File Name" Width="50*" Binding="{Binding FileName}"/>
</DataGrid.Columns>
</DataGrid>
The checkbox column is bound to a bool property on the FileEntity called IsSelected. When I click the checkbox inside the checkbox column the IsSelected property's Setter is not firing.
I also have a Select All button that calls this on the VM:
private void SelectAllExecuted()
{
foreach (var file in Files)
{
file.IsSelected = true;
}
}
This DOES cause the IsSelected's property to fire for each file entity.
Anyone see what's wrong?
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 UpdateSourceTrigger :
<DataGridCheckBoxColumn Header="Selected" Width="55" Binding="{Binding IsSelected, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" IsReadOnly="{Binding IsFixed}" /> (As suggested in this SO post[^].)
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
That did it.
ya, Im an idiot.. never even thought to set it
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
Can anyone share how to add a NIC receive bytes/s counter to a WPF form?
|
|
|
|
|
C# - Performance Counters
Read the counter; add the counter to a WPF window (as a TextBlock or whatever).
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
I've been looking at Magnify shader effects (for example, the one in Shazzam[^]), and I can get this to work OK. Other magnify effects seem to use a similar approach.
However, it appears to be magnifying the on-screen image, i.e. the as-displayed pixels are being enlarged by the effect. I have a large bitmap which is being reduced (via a scale transformation) to fit in a window, and I would like the magnify effect to display the original pixels (i.e. at a higher resolution than the scaled display image). I tried applying the magnify effect internal to the scale transformation, but that doesn't seem to do the trick.
Does anyone know how or if this can be done using pixel shaders? (For info, I'm using WPF .NET 4.6)
Thanks.
Nick.
|
|
|
|
|
If the "scale transformation" is causing a problem, why don't you eliminate that step for this scenario?
WPF can work with "visuals" that are independent of any window.
Don't know what "Shazzam" needs, but maybe it's not what you are giving it.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
I created an attached property of type List<string>. How do you assign list items to the collection in XAML?
<h1>region MyItems Collection</h1>
public static readonly DependencyProperty MyItemsProperty =
DependencyProperty.RegisterAttached("MyItems",
typeof(List<string>),
typeof(MyClass),
new UIPropertyMetadata(null,
new PropertyChangedCallback(OnMyItemsChanged)));
public static List<string> GetMyItems(DependencyObject obj)
{
return (List<string>)obj.GetValue(RightsKeyProperty);
}
public static void SetMyItems(DependencyObject obj, List<string> value)
{
obj.SetValue(MyItemsProperty, value);
}
private static void OnMyItemsChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
{
}
<h1>endregion</h1>
<blockquote class="quote"><div class="op">Quote:</div><TextBox Grid.Row="1"
Grid.Column="1"
Text="{Binding CreditLimit, Mode=TwoWay}"
Width="100"
sec:MyClass.MyItems="" <!--HOW DO I ASSIGN MULTIPLE ITEMS HERE-->
HorizontalAlignment="Left"
Margin="10"/>
</blockquote>
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
If I've guessed what you're trying to do correctly, something like this should work:
<TextBox ...>
<sec:MyClass.MyItems>
<sys:String>Item 1</sys:String>
<sys:String>Item 2</sys:String>
...
</sec:MyClass.MyItems>
</TextBox>
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thanks
is that possible on one line? Maybe {"Item1, Item2"}?
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
|
I'm doing something wrong here. The Getter is called, but neither the Setter nor the callback arn't being called.
My DP
public static readonly DependencyProperty RightKeysProperty =
DependencyProperty.RegisterAttached("InternalRightKeys",
typeof(List<string>),
typeof(AppSecurity),
new UIPropertyMetadata(new List<string>(),
new PropertyChangedCallback(OnRightKeysChanged)));
public static List<string> GetRightKeys(DependencyObject obj)
{
return (List<string>)obj.GetValue(RightKeysProperty);
}
public static void SetRightKeys(DependencyObject obj, List<string> value)
{
obj.SetValue(RightKeysProperty, value);
}
private static void OnRightKeysChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
{
}
My XAML
<TextBox Grid.Row="1"
Grid.Column="1"
Text="{Binding CreditLimit, Mode=TwoWay}"
Width="100"
HorizontalAlignment="Left"
Margin="10">
<sec:AppSecurity.RightKeys>
<sys:String>Item 1</sys:String>
<sys:String>Item 2</sys:String>
</sec:AppSecurity.RightKeys>
</TextBox>
Again, nothing is being called. I get no errors or messages in output
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
That's the expected behaviour for any dependency property set via XAML:
Important: Do not add any logic to these properties, because they are only called when you set the property from code. If you set the property from XAML the SetValue() method is called directly.
The OnRightKeysChanged method should still be called.
NB: You might need to fix the name of the property so that it matches the standard pattern. Since you've declared RightKeysProperty , it should be called "RightKeys" , not "InternalRightKeys" .
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|