Skip to content

Instantly share code, notes, and snippets.

View s-fernandez-v's full-sized avatar

Sergio Fernandez s-fernandez-v

View GitHub Profile
@s-fernandez-v
s-fernandez-v / EventToCommand.cpp
Last active August 19, 2017 17:56
Attached property to connect a Command to a RoutedEvent in NoesisGUI
class EventToCommand
{
public:
static const DependencyProperty* CommandProperty;
static ICommand* GetCommand(const DependencyObject* obj)
{
NS_ASSERT(obj != 0);
auto command = obj->GetValue<Ptr<BaseComponent> >(CommandProperty);
return NsDynamicCast<ICommand*>(command.GetPtr());
@s-fernandez-v
s-fernandez-v / EventBindingExtension.cpp
Created August 19, 2017 18:10
Custom MarkupExtension to connect a RoutedEvent to a Command in NoesisGUI
struct EventBindingExtension: public BaseComponent, public IMarkupExtension
{
EventBindingExtension() { }
const NsChar* GetCommandName() const { return commandName.c_str(); }
void SetCommandName(const NsChar* name) { commandName = name; }
Ptr<BaseComponent> ProvideValue(const void* context) override
{
auto provider = (const XamlReaderProvider*)context;
@s-fernandez-v
s-fernandez-v / Main.xaml
Last active January 30, 2020 09:00
Button: ClickMode
<Grid
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid HorizontalAlignment="Center" VerticalAlignment="Center">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<StackPanel Grid.Row="0">
<StackPanel.Triggers>
@s-fernandez-v
s-fernandez-v / Main.xaml
Last active January 30, 2020 18:02
RepeatButton: Delay and Interval
<Grid
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid HorizontalAlignment="Center" VerticalAlignment="Center">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition/>
@s-fernandez-v
s-fernandez-v / Main.xaml
Last active May 15, 2020 15:33
Button: Custom Styles
<Grid
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
xmlns:noesis="clr-namespace:NoesisGUIExtensions;assembly=Noesis.GUI.Extensions">
<Grid HorizontalAlignment="Center" VerticalAlignment="Center">
<Viewbox StretchDirection="DownOnly">
<Viewbox Width="400">
<StackPanel HorizontalAlignment="Center">
@s-fernandez-v
s-fernandez-v / Main.xaml
Last active January 30, 2020 12:35
Canvas: Content layout
<Grid
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid HorizontalAlignment="Center" VerticalAlignment="Center" Background="LightGray" TextElement.Foreground="Black">
<Grid.Resources>
<LinearGradientBrush x:Key="BgBrush" StartPoint="0,0" EndPoint="1,1">
<GradientStop Offset="0" Color="#FF9BDEFF"/>
<GradientStop Offset="1" Color="#FF69B5FF"/>
</LinearGradientBrush>
<Style x:Key="BorderStyle" TargetType="Border">
@s-fernandez-v
s-fernandez-v / Main.xaml
Created January 30, 2020 18:04
Button: Graphical content
<Grid
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
<Button Padding="0">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
@s-fernandez-v
s-fernandez-v / Aero Matics Regular.ttf
Last active February 24, 2020 09:08
Hello World! Sample